My answer, originally published on Quora.
The most obvious answer:
- Fewer and fewer girls are studying math and computer science in college, and
- Of those women who do graduate in those fields, and who even become programmers, they are likely to leave the field after a few years.
Others have addressed #1 in other answers. I'll address #2, as a former software engineer.
When I was in my twenties, I loved programming. I was very into the tough problems that earn you nerd status and all that. And I really enjoyed working with all of my engineering peers, 90% of whom were men. I was good at programming, was well respected by all my peers (male & female), and got to work on great projects.
So what happened? Well, the Sales & Marketing people disproportionately wanted ME to be the technical person who they took along when visiting the "tech guys" at the customers and prospects. I was referred to as "Nerd Bait" by some of our company's sales people because I was young, reasonably attractive, and loved talking shop with customers.
From there, as a tech person who was always visiting customers, it was only a short leap into Product Management, which I still do today (although I do miss coding).
I've seen the same thing happen to several very competent female engineers, where they ultimately end up in Sales or Marketing or Product Management.