This is an e-mail response I sent to one the leader of our women’s Ruth Bible study. She was asking about the connection b/t Tamar and Ruth (specifically in the case of levirate marriage).
It looks like Tamar was probably a Canaanite. After the death of her first husband she was involved in a Levirate marriage situation. The difference between her and Ruth is that the levirate marriage was an established custom of the surrounding area and only later (in the Mosaic Law) was it set in the Israelite system of ethics and standards that God laid down to preserve His people.
During the original formation of the people of Israel, Abraham to Jacob, you find a lot of things that were sketchy and would have been frowned on later (ie. polygamy, having kids through servants (Abraham), visiting prostitutes (Judah), murder (Simeon and Levi)).But if you look at the overall story that these people are situated in it hardly works out for them in a good way unless God intervenes on behalf of His Name.
You also find good things from the culture that God has sovereignly put into place and later makes them specific to the people of Israel. These things are always re appropriated somehow to define Israel as a specific people that carry His name (ie. circumcision, covenants, levirate marriage, temples, sacrifice, etc). In fact, when they are actually doing it in His name, as the law commands them to do, they are truly fulfilling the original purpose for which God sovereignly in the culture in the first place.
All that to say: levirate marriage existed in the surrounding culture of Judah’s day, Tamar has a claim to this based on the culture, Judah tries to circumvent this claim because his sons keep dying (scripture is pretty clear that they are dying because of their actions and not Tamar’s), Judah puts his own line in jeopardy because his sons keep dying, Tamar recognizes her claim and acts accordingly, and Judah repents for his mistreatment of her and declares her actions righteous (lining up with God’s intentions).
Ruth is different because she comes well after the formation of the people of Israel and the establishment of the law. The law limits things like levirate marriage to the people of Israel because it assumes that the people are following the law in the first place and not leaving the promised land and marrying outside of the people of Israel. Just like Judah the line of Boaz and the line of Naomi are in jeopardy, God fixes this through a Moabitess.