Compared to all animal species, the extremely long time of development of human children requires a stable social environment, because children as the weakest members of the society are very vulnerable in their development, if such an undisturbed environment does not exist. Particularly young women and mothers had and have to be protected from assaults by the protective shield of a practised social code.
From the observation of other primates (and, of course, human experience as well), we know that sexuality is a prevalent cause of social struggles and upheavals. For example, copulating bonobo and chimpanzee pairs like to hide away, in order to avoid being observed by other males during sexual intercourse. Otherwise, in this quite defenceless situation, they run the risk, that a competing or senior male will massively attack and expel the copulating male and then copulate with the female himself.
This tactic of hiding away for copulation to undisturbed seclusion has probably also contributed to a "shame of sexual action", that induces us to copulate in seclusion and not for all the world to see.
We also know from the observation of great apes, that, for example, males hide their erect sexual organs behind a hand, when they are observed by senior males, in order to appease them. Otherwise, there is also the risk, that they will be massively attacked and expelled, if a senior animal sees his harem endangered. We also encounter even such behavioural patterns with humans, thus probably helped to develop the "shame of genitalia", i.e. the anxiety to present your own genitalia not (permanently) openly visible, especially if their condition signals readiness for copulation.
Although this behaviour by senior males also at first appears as selfish claiming of possession or rights, the punishment of sexual activities by junior animals also prevents or governs sexual assaults on established and attractive females. This is the beginning of a social code imposed on society by dominant animals and any violation of this code of conduct will be punished massively. The development of such a social code is therefore by no means constrained to humans, and neither is that of a punitive system for enforcement.