It could very well be that women have had the potential to outperform men in academic tasks since Socrates, but never had the chance until widespread and egalitarian schooling.
I'm not even 40 and in my education, I heard several STEM teachers say that girls can't hack it. The latest of which occurred a mere 10 years ago at a public university. "Egalitarian schooling" is an extremely novel concept and many parents and teachers (men and women) still haven't bought in on the idea.
They hack it perfectly fine in microbiology,(71% female) and veterinary science (65%). The main issue is that they really aren't represented in computer science and engineering STEM fields, as well as research scientists. But if you looked at all the STEM fields, it is probably more even, or there even are significant male shortages in some.
The issue is that a lot of people don't really define stem as stem, they define it as RCE-research, computers, and engineering.
Besides the point. Have you ever had a favorite teacher who told you that you were destined for failure? Probably not, that teacher is never gonna be your favorite -- and spending a semester, or even years, with that teacher might well sour you on the subject even if it was your favorite.
Very true. "Egalitarian" here is highly relative. Schools now are certainly more egalitarian than they were a few centuries ago (when barely anyone could even attend!) but they are still a long way off.
I'm optimistic that we will eventually reach a fully egalitarian future, but pessimistic at how much work is left to do.