The explanation I've seen a lot is that once men realized computers could be used for more than trivial math they took over the field. It's obviously more nuanced but I do think it's mostly out of sexism, which is why organizations like Girls Who Code are so valuable.