"Then Judah said to Onan, "Go in to your brother's wife, and perform your duty as a brother-in-law to her, and raise up offspring for your brother." Onan knew that the offspring would not be his; so when he went in to his brother's wife, he wasted his seed on the ground in order not to give offspring to his brother. 10But what he did was displeasing in the sight of the LORD; so He took his life also." Genesis 38:9
This passage in the Bible is the oldest one I can think of, I am sure it has been recorded much much earlier but I won't attempt to answer it. Maybe someone with knowledge about some other parts of the world can come up with another example.