Ancient rules around sex essentially evolved to protect human offspring, whether in patriarchal or (the admittedly few) matriarchal societies. Because human children require extended periods of devoted care in order to thrive. Both mother and child are vulnerable during this period, both from predation (animal & human) and from lack of resources. Since the mother has to spend so much time caring/nursing the infant it is difficult for her to meet her own nutritional needs without help. Example: most mammal babies can walk soon or even immediately after birth. Human babies can take up to two years to do so.
This is why our family structures developed - with marriage at its centre. Even in modern times, with social welfare protections in place, a male who deserts his offspring faces censure by the community.