Sometimes it seems like the biblical writers are chasing a random story, like Alice chased the white rabbit.

When reading the Bible, I make an important assumption: It makes sense. No matter what position you take on authorship, someone, somehow and some-when put the text into exactly the form we have it today. Even if it doesn’t make sense to us, surely it must have made sense to whoever put the last bit of ink on the parchment. Assuming that the text is an artistic whole frees us from second-guessing the composers of the biblical text and allows us to simply read it.

This assumption is challenged any time the form of the text we have doesn’t make sense on first reading. Case in point: Genesis 38, the story of Judah and Tamar.

The Joseph narrative (Gen 37–50) is one of the most compelling stories in the Hebrew Scriptures. Sometimes called “the Joseph novella,” it has a dramatic “rags-to-riches” plot, complete with attempted fratricide, sexual tension, unjust imprisonment, mistaken identity, and intrigue of all kinds.

But just when the story’s main conflict is ratcheting up, Gen 38 intrudes. Joseph’s storyline is suspended while the narrator follows a bunny trail about Judah’s misadventures with his daughter-in-law. You can read Genesis 37–50 straight through or you can skip chapter 38 and not miss anything. It creates such a marked disturbance in the Joseph story that the salient points at the end of chapter 37 are reiterated at the beginning of chapter 39 so the reader can get re-oriented.

Moreover, Genesis 38 is a complete story in its own right with a clear beginning, middle, and end. It purports to be simultaneous with the surrounding narrative: “It happened at that time” (38:1). But in the time that Joseph is taken from Israel to Egypt, Gen 38 covers two generations of Judah’s family history. The setting changes from Shechem to Chezib, and of all the characters, only Judah appears in both stories. Plot, setting, characters, and timeline—none of it fits.

So why is it even there?

For one thing, Judah is an important character, not only in the Joseph story, but in the history of Israel: The Davidic royal line descends from Judah and Tamar’s son Pharez, through Ruth and Boaz (Ruth 4:12–22). So this story must be included somewhere, and I assume this is the place that made the most sense.

Furthermore, Genesis 38 and 39 form a juxtaposition: elements which are placed next to one another in order to invite comparison and contrast. So let’s do that:

Both chapters hinge on matters of sexual ethics. Judah and his sons are sexually immoral in their treatment of Tamar. Judah’s eldest son, Er, marries Tamar. When he dies, it becomes his brother Onan’s duty to care for her and give her offspring in Er’s name. Instead, Onan uses her for his own cheap gratification. When he also dies, the duty falls to the youngest brother Shelah, who Judah withholds. And then Judah uses Tamar—unwittingly, but still immorally. By contrast, Joseph nobly refuses the sexual advances of his master’s wife (Gen 39).