Please re-read the passage:
8
3 Then Judah said to Onan, “Unite with your brother’s widow, in fulfillment of your duty as brother-in-law, and thus preserve your brother’s line.”
9
Onan, however, knew that the descendants would not be counted as his; so whenever he had relations with his brother’s widow, **he wasted his seed on the ground, to avoid contributing offspring for his brother. ** 10
What he did greatly offended the LORD, and the LORD took his life too.
What did he do that greatly offended the Lord? He wasted his seed on the ground to avoid contributing offspring for his brother.
I suppose you could interpret it and say that the Lord was offended by the fact that he wasted his seed on the ground, but that’s reading into it. The way it’s written suggests nothing of the kind. Of course it’s possible, but it’s hardly definite, and all we know is that the Lord was offended by his spilling his seed on the ground to avoid contributing offspring for his brother.
Presumably Genesis and Ruth were written by different people at different times. Look at the New Testament, there Jesus stops people from stoning a woman. In Deutoronomy stoning was a common punishment for sexual offenses.
Can you use passages from the New Testament to say that people were not stoned for adultery in the Old Testament even though it clearly says they were?
You can’t use passages from Ruth to contradict what’s clearly written in Genesis.
This is not what it says in the passage itself, you have to spin the passages a lot to get them to mean that.
It says that Onan wasted his seed on the ground, to avoid contributing offspring for his brother. What he did greatly offended the LORD
God made many commandments in the Old Testament, if he wanted to explicitly forbid contraception he would have done it. Contraception was around back then, especially in Egypt where Moses and the Israelis lived before the Exodus.