Why did God slay Onan?
Those sentences which are colored in orange are from Maharishi Dayananda Saraswati book Satyarth Prakash (The Light of Truth) and those which are colored in black are Jerry Thomas’s response.
"And Er, Judah's first-born, was wicked in the sight of the Lord; and the Lord slew him. And Judah said unto Onan, Go in unto thy brother's wife, and marry her, and raise up seed to thy brother. And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother's wife, that be spilled it on the ground, lest that he should give seed to his brother, and the ting which he did displeased the Lord: wherefore, he slew him also." (37:7 – 10.)
C. Now, it must be clear to all that these are the doings of man, not of God. Onan entered into Niyoga* with Er's wife why did God slay him? Why did not He guide his understanding?
*This also conclusively proves that Niyoga waa in vogue in all countries in ancient time.
Answer: This correct passage reference is Genesis 38:7-10.
Now, it appears that Maharishi is not even reading the passage that he quotes.
What was the sin of Onan?
Onan was clearly told what his duty is:
Genesis 38:8 And Judah said to Onan, "Go in to your brother's wife and marry her, and raise up an heir to your brother."
Onan knew the cost and his duty:
Genesis 38:9 But Onan knew that the heir would not be his; and it came to pass, when he went in to his brother's wife, that he emitted on the ground, lest he should give an heir to his brother.
The question one should be asking is if Onan did not want Tamar to conceive, why did he go to her in the first place? He could have simply told that he do not want to have such an heir for his brother.
In other words, this was an abuse of a woman under the pretext of a duty. The LORD God does not like those who abuse woman.
Genesis 38:10 and the thing which he did displeased the LORD; therefore He killed him also.