
Genesis 38 is the chapter that interrupts Joseph's story. Joseph has just been sold to Egypt. The next chapter should follow him. Instead the Torah pivots to Judah — the brother who proposed the sale, who then leaves his brothers, marries a Canaanite woman, and has three sons: Er, Onan, Shelah. Er marries Tamar and dies — the LORD found him wicked. Onan refuses to fulfill levirate duty and dies. Judah fears for Shelah and sends Tamar back to her father as a widow.
When Judah himself goes to Timnah for sheepshearing, Tamar veils herself and sits at the road. He sleeps with her, pledging his seal, cord, and staff. She conceives. When Judah hears she is pregnant he orders her burned. She produces his seal, cord, and staff: "By the man who owns these I am pregnant." Judah recognizes them.
He says: "She is more righteous than I." This is one of the most dramatic lines in Genesis — a man confronting his own hypocrisy and naming it.