Genesis 38:6-8

38:6 Judah acquired a wife for Er his firstborn; her name was Tamar. 38:7 But Er, Judah’s firstborn, was evil in the Lord’s sight, so the Lord killed him.

38:8 Then Judah said to Onan, “Have sexual relations with your brother’s wife and fulfill the duty of a brother-in-law to her so that you may raise up a descendant for your brother.”