Read this passage and open each verse for the full verse feed and commentary tools.
6And Judah took a wife for Er his first-born, and her name was Tamar. 7But Er, Judah's first-born, was wicked in the sight of the LORD; and the LORD slew him. 8Then Judah said to Onan, "Go in to your brother's wife, and perform the duty of a brother-in-law to her, and raise up offspring for your brother." 9But Onan knew that the offspring would not be his; so when he went in to his brother's wife he spilled the semen on the ground, lest he should give offspring to his brother. 10And what he did was displeasing in the sight of the LORD, and he slew him also.
Genesis 38:6-10 (RSV)