Lineage of Jesus Christ
The story of Judah and Tamar is of notable significance. It is placed here in the middle of Joseph's story, not because it is directly related, but because the events took place after Joseph was sold into slavery and before the sons of Jacob traveled to Egypt. As can be seen, the end of the account is the birth of twin sons, Perez and Zerah, to Tamar. These two boys become important fathers in the lineage of future kings. If Onan and Judah had had their way, Tamar would not have given birth to the very son whose descendants include both King David and Jesus Christ.
Although the account does prominently show some of Judah's shortcomings, that is not its main purpose. This account is about proving lineage. Both Luke 3:33 Luke 3:33Which was the son of Aminadab, which was the son of Aram, which was the son of Esrom, which was the son of Phares, which was the son of Juda,
American King James Version×and Matthew 1:3 Matthew 1:3And Judas begat Phares and Zara of Thamar; and Phares begat Esrom; and Esrom begat Aram;
American King James Version×show that Perez is the son of Judah through whom Jesus was descended. The Messiah would be a descendant of Judah (see Genesis 49:10 Genesis 49:10The scepter shall not depart from Judah, nor a lawgiver from between his feet, until Shiloh come; and to him shall the gathering of the people be.
American King James Version×). But why the detailed version of this lineage? Many of the other lineages in Genesis simply list who fathered whom—wouldn't that suffice? No, for without the story of how Tamar conceived and Judah's subsequent public acknowledgment of fatherhood, the Jewish heritage of the descendants of Perez, including Jesus, may have been unknown or disputed.
(For further information on the descendants of Perez and Zerah, including the significance of the breach and the scarlet thread, please see "The Throne of Britain: Its Biblical Origin and Future".)
Another interesting item in the account is Judah's statement: "She has been more righteous than I." This was certainly true. Notice that although Tamar did dress as a prostitute, it was Judah who solicited her. Yet later, Judah sentenced Tamar to be burned as punishment, even though he had been very willing to go into one whom he thought was a harlot and participate in such a sin himself. In contrast, Tamar was ensuring that an heir would be raised up to her husband (compare Deuteronomy 25:5-6 Deuteronomy 25:5-6  If brothers dwell together, and one of them die, and have no child, the wife of the dead shall not marry without to a stranger: her husband's brother shall go in to her, and take her to him to wife, and perform the duty of an husband's brother to her.
 And it shall be, that the firstborn which she bears shall succeed in the name of his brother which is dead, that his name be not put out of Israel.
American King James Version×), a responsibility that Judah had willfully abandoned (Genesis 38:14 Genesis 38:14And she put her widow's garments off from her, and covered her with a veil, and wrapped herself, and sat in an open place, which is by the way to Timnath; for she saw that Shelah was grown, and she was not given to him to wife.
American King James Version×).