In the pre-Enlightenment era they thought there was one biological sex, male, with different degrees of perfection. Men were perfect males, and women were literally deformed, mutated males. So ovaries were undescended testicles, the vagina was an inverted penis, women's skeletons were 'deformed male skeletons' etc. Now, this theory was completely wrong and it goes to show that the theory itself didn't matter - everyone knew who the women were, everyone knew women got pregnant and had babies, everyone treated women like shit. The fact they were thought to be lesser males didn't lead to them being treated any better.
How did sexual reproduction work? They thought men's sperm contained a little human being inside it, and when it was placed inside the woman's body (which was just an empty cavity) this was like planting a seed. And the little human expanded and grew. Women contributed nothing to the process except being a vessel.
In the Enlightenment they managed to see gametes under the microscope and got to chop up some bodies (autopsies of women had been very rare before that point) and they realised that women weren't just mutated males, a subset of males, but were actually a different kind of thing - another biological sex. And they realised that women produced their own gametes which contributed to sexual reproduction, and that ovaries weren't just atrophied testes, and the vagina wasn't just an inverted penis. So the theory switched from the one sex model to the two sex model - females were their own biological category.
The two sexes always existed in reality, it's just that the Ancient Greeks didn't have the scientific knowledge to appreciate this. To say there was no such thing as a female skeleton in pre historic times is like saying there was no such thing as radiation, or bacteria, and that witches and magic existed. The theory changed, but reality was always the same.
I have to emphasise that this was just a change in the scientific theory. This didn't change how women were treated socially or in reality one bit. Women didn't get more respect when they were regarded to be a subset of males. What is interesting is that the scientific theories of the sexes didn't impact very much at all on how women were treated. Whether women were seen as males, or females, their social roles stayed the same and they were still oppressed.