Many years ago, there was a man named Judah, and he had three sons. The eldest, named Er, married a woman named Tamar. Er was a wicked man, and the God of Israel struck him dead because of his evil ways.
This left Tamar childless, which meant two things: her late husband would have no heir, and Tamar might be left to survive on her own, which was very difficult, if not close to impossible, for single women and widows in those days.
Judah told his second son, Onan, to take Tamar as his wife. If she conceived, that firstborn son would become Er's heir. Onan agreed to marry her, but used means to keep her from becoming pregnant. God saw this, that he was undermining the plan Judah had for Tamar and Er's heritage, and so God struck him down dead.
Judah had one son left, Shelah. He was but a child. It would be many years before he would be old enough to have a wife, so Judah took in Tamar as part of his household, to wait for that day. Tamar, however, had doubts. This son might die after marrying her, too. Was she bad luck? Would he still be able to bear children by the time he was old enough? Would he even want her, or was she wasting her life waiting for this child to grow up? Over time, Shelah, grew into a man, but Tamar becoming his wife was always sidestepped....avoided....
During this waiting period, Judah's wife died. He grieved her death, because he loved her. However, in time, his heart began to heal, and he desired the warmth of a woman's body. Tamar found out that Judah was going to shear his sheep, and when the shepherds did this, often they visited the temple of the local gods, where there were harlots waiting to give them a good time.
Tamar took off her widow's clothes, and dressed herself as a harlot, and presented herself to Judah at a shrine along the way that she set up. Although her face remained veiled, they spent a night of passion together. She asked for payment, and he said he would send her a goat from his flock. She asked for collateral until it was sent. So, he left his seal and its cord, and his staff.
Soon, it was discovered that Tamar was with child. This enraged Judah, and he sentenced her to death for prostitution. (Double standard, there!)
Tamar said, "I am pregnant by the man who owns these," and she brought out the things that Judah gave her. Judah recognized his folly, calling her better than himself. She found a way to give Er an heir, since Judah would not give her in marriage to Shelah. Her life had been spared.
She gave birth to two twins, Perez, and Zerah. Judah took care of her and their sons, for the rest of her life, but he did not sleep with her again.
From Tamar's line came King David, and later on, Jesus Christ.