My though is this:
The underlying purpose of religion and even social mores is to maintain social order.
A big problem with sex is of course that until the last few decades, it had the regular possibility of resulting in children - so the need was to have someone provide for that children. Shotgun marriages, and the strong social pressure for women to abstain outside of marriage was specifically to try to prevent such problems.
The other problem, as anyone who’s spent an evening in a rowdy bar can attest, is that women cause fights just by being there. When males flock to attractive females, absent serious social controls, fights follow. (I suppose to some extent catfights follow flocking females…)
As a result, most societies have a set method of saying “this woman belogs to this man”. It solves several problems - men who go after someone else’s woman have been fair game; in places like Spain, IIRC, it was common to escape conviction if you shot your wife’s lover and even the wife . The husband was presumed to be the parent of any child born in wedlock, and obliged to support them.
Similarly, countries with legal polygamy have the concurrent obligation that the husband must support all those wives. I would suspect it is less about women wanting to flock, since in a lot of those countries the woman has little choice. More likely it is about prestige and position. and supporting family. Marriage has always been a way to cement relationships between families and clans; it conveniently unloads those girls old enough to leave the nest on someone else who can better make use of them. Sadly in all this, women in many societies have been treated as property.
Whether they are called wives, concubines, or mistresses, most societies have had a way for a man to indulge himself to the extent he can affford and get away with.
I’m not sure the imbalance or shortage of women leads to that much social unrest; after all, the average wifeless Joe can always aspire to become a married man eventually, and that’s a social restraint; for every Sultan with 300 wives, there are probably a million who can only afford the one wife. Society is full of large groups unmarried, unattached aggressive young men regardless of the social norms - sailors and soldiers are legendary for their behaviour on and of duty. Society has evolved various means, such as strict discipline, to handle them.
The social norms are full of means to handle unattached women. The early Isrealites, for example, could have multiple wives; had to marry the dead brother’s wife i.e. support her, whether you wanted to or not, Onan! Joseph similarly was obliged to take in Mary for some reason. Solomon’s problem wasn’t dividing up babies, but finding time for wives…
I also wonder about social inclinations to monogamy. You find interesting variations through history; even many primitive societies had the multiple wives for the chief or others. That way, one single widow was not left unsupported. (Although there is the scene in “A Man Called Horse” about the old lady whose husband dies; they take all “his” things and leave her to die in the snow, since what good is an old woman?) Rome, IIRC, had one wife in Rome and one foreign wife? Wasn’t that the Cleopatra story? They also had a much more free divorce system, provided the wife was supported.
I’m not sure where our Christian monogamatic heritage came from, although I once heard some comments in college about St. Paul and his dislike of women and admiration of the Greek lifestyle - the Greeks, IIRC did have a more monogamatic inclination.