This will probably be controversial, somewhat of an adult subject, and to some extent a companion to an earlier post.
Genesis 38:6-10 And Judah took a wife for Er his firstborn, whose name was Tamar. And Er, Judah's firstborn, 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 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.
Onan’s sin is not that traditionally attributed to him ("onanism" is an English term for masturbation). The Old Testament phrase “he went in unto her” clearly denoted sexual intercourse. Onan abused the occasion to enjoy the pleasure of his deceased brother's wife, but disdained his obligation to raise up an heir in his brother's name.
Compare other uses of the phrase:
Gen. 16:4 - And he went in unto Hagar, and she conceived: and when she saw that she had conceived, her mistress was despised in her eyes.
Gen. 29:23 - And it came to pass in the evening, that he took Leah his daughter, and brought her to him; and he went in unto her.
Gen. 30:4 - And she gave him Bilhah her handmaid to wife: and Jacob went in unto her.
Gen. 38:2 - And Judah saw there a daughter of a certain Canaanite, whose name was Shuah; and he took her, and went in unto her.
(See also Judges 16:1; Ruth 4:13; II Sam. 12:24, 16:22; Ezekiel 23:44)