Then Judah said to his daughter-in-law Tamar, “Live as a widow in your father’s house until my youngest son Shelah grows up.” So Tamar went home to her parents, but Judah worried that Shelah would end up dead like his brothers.
Turn around my daughters and go back home, for I’m too old to marry again. Even if I thought there was still hope for me, and married today and gave birth to sons,
Onan, however, did not want to produce a child that would not be his own rightful heir, so whenever he and Tamar had intercourse, he purposely spilled his semen onto the ground to keep her from getting pregnant and having a child that would belong to his dead brother.