Judah finds a lady named Tamar for his first son, but the wicked son dies. You know what that means. Oh, you don't?
Well, Judah explains to his second son Onan that he must follow the laws of Levirate marriage, which are elaborated in Deuteronomy 25:5-10. These laws dictate that the brother of a dead husband must marry the widowed wife (his sister-in-law) and produce an heir in order to keep the lineage of the deceased brother alive.
But when it comes time for Onan to ejaculate during sexual intercourse, he withdraws his penis and "spills his seed" on the ground. This is what we call coitus interruptus, or, um, pulling out.
Here's the deal. Onan knew any baby Tamar bore would not be his heir, but his brother's.
Well, that's just not going to fly with God, so he kills Onan.
Judah sends Tamar back to her father's house until Judah's youngest son, Shelah, is old enough for marriage.
After a while, Tamar takes matters into her own hands. She disguises herself as a prostitute and approaches Judah.
She asks for three very personal items: signet, cord, and staff. She will hold these as a pledge until Judah pays her with a kid from his flock. That's like the biblical equivalent of a social security card, credit cards, and driver's license.
Next thing you know, Tamar conceives a baby.
Judah learns that Tamar is pregnant "by harlotry" (38:24 NRSV), and he declares that she must be burned.
Tamar makes it known that the father of her baby is none other than… Judah. Oh, and she has his social security card. No one can deny it.