In the ancient ages it was the norm, quite naturally, then quite not amusingly it never changed, this mindset. No matter what women did, their main contribution to society was to give birth to male children, with time giving birth to female children became a vice. Giving birth to none became a sin. Barren women (!) were treated as bad omen during holy, joyous occasions, they were kept away from such ceremonies like widows.
The tragic thing is centuries later, even today barren women are treated as bad omen by many families, and the liability of being barren is brazenly stamped upon their forehead, till date! Even though everyone knows (almost) that the husband can be impotent too. As for giving birth to male child, it is damn priority in most families!