“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.”
King James Version (KJV)
38:7 And Er was wicked in the sight of the Lord - That is, in defiance of God and his law. And what came of it? Why God cut him off presently, The Lord slew him. The next brother Onan was, according to the ancient usage, married to the widow, to preserve the name of his deceased brother that died childless. This custom of marrying the brother's widow was afterward made one of the laws of Moses, #Deu 25:5|. Onan, though he consented to marry the widow, yet to the great abuse of his own body, of the wife he had married, and the memory of his brother that was gone, he refused to raise up seed unto his brother. Those sins that dishonour the body are very displeasing to God, and the evidence of vile actions. Observe, the thing which he did displeased the Lord - And it is to be feared, thousands, especially of single persons, by this very thing, still displeased the Lord, and destroy their own souls.
38:11 Shelah the third son was reserved for the widow, yet with design that he should not marry so young as his brothers had done, lest he die also. Some think that Judah never intended to marry Shelah to Tamar, but unjustly suspected her to have been the death of her two former husbands, (whereas it was their own wickedness that slew them) and then sent her to her father's house, with a charge to remain a widow. If so, it was an inexcusable piece of prevarication; however Tamar acquiesced, and waited for the issue.