Greater love has no one than this, that someone lay down his life for his friends.
The story of Judah's problems in engendering a proper posterity seems awkwardly inserted like a disconnected interlude between Genesis 37 and 39. One would wonder, "What is the purpose of cutting of the narrative of Joseph story with the outrageous story of Judah and Tamar?"
The writers of the Hebrew Scriptures wrote thematically in order to make a point. Missing the theme, one misses the important points of the story. In this case the theme is found in the connection between the lives of Joseph and that of Judah.
We are told that previously, Joseph had been 'brought down' to Egypt (Genesis 39:1) while Judah 'went down' from his brothers to marry a Canaanite woman. This union disqualified Judah from the rights of first-born after his three older siblings also disqualified themselves (Genesis 38:1-2).This tells us of the spiritual direction of the concerned person. In this case, the writer points out the theme of divine retribution. As Judah sent his brother Joseph 'down', so God sends him.
Amos the prophet brings the idea of divine retribution for evil doing. He says, Thus says Adonai: "For three transgressions of Israel, and for four, I will not revoke the punishment, because they sell the righteous for silver … (Amos 2:6). This statement is reminiscent of Joseph, and of the Master. Amos continues and says, Do two walk together, unless they have agreed to meet? … Does disaster come to a city, unless Adonai has done it (Amos 2:3-6). Thus he reminds people that, a curse that is causeless does not alight (Proverbs 26:2).
Sometimes we do not understand why our lives take certain turns and we wonder if Hashem really watches. It is at these times that we should ask ourselves if what is happening to us might only be a reflection of our sinful actions. One who can do that has really learned the fear of God.
After Judah repented and understood what Tamar did because of love for the covenant of Abraham, Judah was used to turn the tide of events for his whole family. We learn later that, as he had first sold his brother for his own benefit, he offers his life as ransom to save that of Benjamin's, Joseph brother. This in turn started the course of events that would save all of Jacob's family from famine and death. From Judah also comes He who would also give His life as ransom for our sins.
May Abba grant us like Judah to able to start on the way up and come to the understanding of our sins (Genesis 38:12, 26). This is the beginning of the way to the Promised Land!