Preface: This might not be the exact sub-reddit to post under, but I'm hoping someone might have some historical information that could help shed light on the issue.
I've been thinking about this question a lot lately. Originally, I was thinking of it more from the perspective of Islam. It's quite clear in the Koran that sex outside of marriage is forbidden. Similarly, acts of sex outside of marriage seem to be condemned or discouraged in Buddhism, Hinduism, Judaism and most denominations of Christianity.
Regardless of your opinions on religion, it seems like there's more to it than mere coincidence that almost all of these religions have such an attitude towards these acts. I don't imagine someone will have a full answer, but if anyone has any information that could be useful, or perhaps point towards a book or paper that discusses this topic, it would be greatly appreciated.
These sorts of cross-cultural observations can sometimes be a bit above our paygrade here. You might try /r/AskAnthropology.
Concerning Islam: Scholars of Sunni jurisprudence since the time of al-Juwayni (died 1085CE) and his student al-Ghazali (died 1111CE) have written that Islamic laws are aimed to protect five universal objectives: religion, life, intellect, progeny, and wealth. Protection of progeny occurs on the level of the species, families, and individuals. The prohibitions and punishments related to fornication are seen as means towards safeguarding progeny. Some scholars explain that licit sex is reduced to situations where paternity is reasonably certain, thus simplifying assigning and enforcing responsibility for the care and support of mother and child, during pregnancy and later while raising the child. Being reasonably certain about lineage is also needed for carrying out inheritance laws.
Scholars of Sunni creed note that protection of the five universal objectives listed above is sharedby all revealed religions, even if the specifics differ from religion to religion.
Sources:
From a sociological perspective, one of the roles of religion is getting morality/establishing and enforcing "right and wrong". Part of this can can also be seen as a way of discouraging conflict or competition within the population (kind of like a glue)
I know citing a textbook isn't ideal, however it's all I have on my phone in a quick you're of reply:http://books.google.com/books?id=NE7fykwlOl8C&printsec=frontcover&output=html_text