As husbands go, Tamar is spectacularly unlucky. To begin with she marries the eldest son of Judah, (Jacob's fourth son by Leah.)
But he is bad, and then dead.
Next she marries his brother, hoping to have children by him that will inherit the older brother's estate, but this doesn't appeal to the bridegroom so he, to put it politely, as the bible does, 'spills his seed'.
So he is also bad, and then also dead.
Tamar is now a double widow and childless. Judah promises his youngest son to her (when he comes of age) but when he does grow up there is still a distinct ongoing absence of wedding bells. In reality Judah is content for her to die a widow, lonely and unmarried. Being an enterprising woman who owns a few veils she decides to take matters into her own hands.
At this point, suspend all notions of 21st Century acceptable moral behaviour, and remember that in this story all the males come off consistently worse than the female....
Tamar dons one of these veils, a particularly fetching one, and goes out to meet her father in law on the road. Mistaking her for a prostitute he sleeps with her in return for.......(some heavy gold coins/a necklace of pure silver/a bushel of fine spices?)
She really wants that goat so as a pledge, he leaves his seal and staff with her, and later sends the goat to her via a friend, to get his seal and staff back. But she is nowhere to be found.
Three months later, Tamar is discovered to be pregnant. In an unbelievably hypocritical storm of fury, Judah orders her to be put to death for unlawful prostitution. She swiftly sends him a message, along with the seal and staff - 'I am pregnant by the man who owns these (Gen. 38:25).
At last Judah admits his fault - he ignored her sad plight and withheld his third son from her. She is 'more righteous than I' (Gen. 38:26). A pretty amazing admission for an, as yet, unreconstructed Old Testament male. Tamar will, through the birth of twin boys, have an honoured place in the blood line of the Messiah, who is graciously not above being born from such bizarre ancestral goings on.