Genesis 38:9

9 and Onan knoweth that the seed is not [reckoned] his; and it hath come to pass, if he hath gone in unto his brother's wife, that he hath destroyed [it] to the earth, so as not to give seed to his brother;

Genesis 38:9 Meaning and Commentary

Genesis 38:9

And Onan knew that the seed should not be his
Should not be called a son of his, but a son of his brother Er; this is to be understood only of the firstborn; all the rest of the children born afterwards were reckoned the children of the real parent of them; this shows this was a custom in use in those times, and well known, and was not a peculiar case: and it came to pass, when he went in unto his brother's wife;
to cohabit with her, as man and wife, he having married her according to his father's direction: that he spilled [it] on the ground, lest he should give his seed to
his brother:
lest his brother's wife he had married should conceive by him, and bear a son that should be called his brother's, and inherit his estate; and this is the sin, which from him is called Onania, a sin condemned by the light of nature, as well as by the word of God, and very prejudicial to mankind, as well as displeasing to God, as follows:

Genesis 38:9 In-Context

7 and Er, Judah's first-born, is evil in the eyes of Jehovah, and Jehovah doth put him to death.
8 And Judah saith to Onan, `Go in unto the wife of thy brother, and marry her, and raise up seed to thy brother;'
9 and Onan knoweth that the seed is not [reckoned] his; and it hath come to pass, if he hath gone in unto his brother's wife, that he hath destroyed [it] to the earth, so as not to give seed to his brother;
10 and that which he hath done is evil in the eyes of Jehovah, and He putteth him also to death.
11 And Judah saith to Tamar his daughter-in-law, `Abide a widow at thy father's house, till Shelah my son groweth up;' for he said, `Lest he die -- even he -- like his brethren;' and Tamar goeth and dwelleth at her father's house.
Young's Literal Translation is in the public domain.