Genesis 38:9, 10 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 he spilled it on the ground, lest that he should give seed to his brother. And the thing which he did displeased the Lord: wherefore he slew him also.
“The seed” was important to the Lord, for in the seed resided The Promise. The promise was that from the seed of Judah (and Jacob and Isaac and Abraham) would come The Seed who was promised to Adam and to Abraham; that Seed would crush the head of the Enemy who brought sin and death; that Seed would be a blessing to the nations; that Seed would be Jesus of Nazareth, the seed of the woman and the Son of God, the Savior who would bring people back to the Kingdom.
For this reason the seed of Onan, son of Judah, was important: it was the Love of God for all people. Onan spurned the Love of God, which was in the promise of the seed. The Lord was so displeased with Onan that He killed him. Unbelief and rejection of God’s promise is a serious matter. Now the rest of God’s people know that, too: ”Do not displease the Lord by making light of the Gospel!”
For some reason we don’t know, God had slain Er, Judah’s oldest son. The next brother, Onan, was told to go in to the widow, Tamar. Legally, the son born to the widow receives the name and inheritance of the dead brother. Onan refused to do that for whatever sinful reason, thereby despising the Word of God.
Onan possibly did not know about the seed promise, but he should have. Whether he rejected God intentionally or in ignorance, God held him responsible, and He killed him. Harsh? Yes, to a human mind, but to the Lord it was a capital offense, like abortion. This ”spilling” was crucifying afresh the Son of God. Watch out!