Moses
Genesis 38:9BSB·traditional attribution

But Onan knew that the offspring would not belong to him; so whenever he would sleep with his brother’s wife, he would spill his seed on the ground so that he would not produce offspring for his brother.

Matthew Henry Presbyterian @wholebiblehenry

Here is, 1. Judah's foolish friendship with a Canaanite-man. He went down from his brethren, and withdrew for a time from their society and his father's family, and got to be intimately acquainted with one Hirah, an Adullamite, Gen 38:1. It is computed that he was now not much above fifteen or sixteen years of age, an easy prey to the tempter.

Commenting on Genesis 38:1-11

John Gill Reformed Baptist @doctorgill

And the thing which he did displeased the Lord,.... Being done out of envy to his brother, and through want of affection to the memory of his name; and it may be out of covetousness to get his estate into his own hands, and especially as it frustrated the end of such an usage of marrying a brother's wife; which appears to be according to...

Adam Clarke Methodist @methodicalclarke

Onan knew that the seed should not be his - That is, that the child begotten of his brother's widow should be reckoned as the child of his deceased brother, and his name, though the real father of it, should not appear in the genealogical tables.