Tamar was married to Judah's son, Er, whom the Lord killed due to his wickedness. Judah then gave his next son, Onan, to Tamar to provide a child, he refused and that refusal led the Lord to take him as well. Judah was afraid to lose his only remaining son and attributed the deaths of his first two sons to Tamar in some way so he kept Shelah from her. She resorted to a ruse to ensure justice and became a woman in the line of the king and the Messiah.