According to the "religious economies" school of thought, celibacy was a tradition that religions adopted to signal their credibility to churchgoers and potential converts. Devotion to a religion is costly and risky for parishioners, since they spend time, money, and it determines their fate in the afterlife. Priests cannot prove that their religion is the correct way to the afterlife, which makes it a risky proposition for the lay followers. However, celibacy allows priests to assure churchgoers of their sincere belief in their religion's conception of afterlife and the steps their faith prescribe to reach it, because the priests take on enormous personal costs in service to it.
In the case of the Catholic Church during the Medieval Era, the practice of Celibacy may have been a measure to prove to the public that money tithed to the Church would not be inherited by the children of the priests.
Source: Larry Witham, Marketplace of the Gods
This is a matter of much dispute because what we had starting from the early modern era were societies which traditionally didn't not care about fidelity, virginity or fatherhood (e.g. the Iroquois) and we had societies which regarded it as something to kill people over (e.g. the Sicilians).
But, sadly, no transition is recorded in history books. So it's a topic not so much for historians as for the social sciences.
I've explained the materialist POV of the Second Wave feminists and the Marxists and over as ask social science.
The relevant passages in Engels are the following. Once hunter gatherers become agrarian the men, who've previously been the property of the women, get to own fields, slaves and herds and therefore need to produce children of undisputed paternity, e.g. someone they could bequeath it all to:
With the herds and the other new riches, a revolution came over the family. To procure the necessities of life had always been the business of the man; he produced and owned the means of doing so. The herds were the new means of producing these necessities; the taming of the animals in the first instance and their later tending were the man’s work. To him, therefore, belonged the cattle, and to him the commodities and the slaves received in exchange for cattle. All the surplus which the acquisition of the necessities of life now yielded fell to the man; the woman shared in its enjoyment, but had no part in its ownership. The “savage” warrior and hunter had been content to take second place in the house, after the woman; the “gentler” shepherd, in the arrogance of his wealth, pushed himself forward into the first place and the woman down into the second. And she could not complain. The division of labor within the family had regulated the division of property between the man and the woman. That division of labor had remained the same; and yet it now turned the previous domestic relation upside down, simply because the division of labor outside the family had changed. The same cause which had ensured to the woman her previous supremacy in the house – that her activity was confined to domestic labor – this same cause now ensured the man's supremacy in the house: the domestic labor of the woman no longer counted beside the acquisition of the necessities of life by the man; the latter was everything, the former an unimportant extra.
the passage most dear to the feminists:
Monogamous marriage comes on the scene as the subjugation of the one sex by the other; it announces a struggle between the sexes unknown throughout the whole previous prehistoric period. In an old unpublished manuscript, written by Marx and myself in 1846, [The reference here is to the German Ideology, published after Engels’ death – Ed.] I find the words: “The first division of labor is that between man and woman for the propagation of children.” And today I can add: The first class opposition that appears in history coincides with the development of the antagonism between man and woman in monogamous marriage, and the first class oppression coincides with that of the female sex by the male.
That was Engels. He is old but very rigorous in his stance. There also are some superficial but new and fashionable thinkers like David Graeber. In his 2011 book he only regards the more recent past, the conflict between "the whore of Babylon" and the countryside patriarchs writing the bible. That conflict he traces to one between what he calls the (rural) "baseline communism" and the monetary economies you'd find in a city.