Interesting story in Genesis 38. I am going to condense it down a bit.
Judah, son of Jacob, had three sons. Er, Onan and Shelah. Er was married to Tamar but he was killed, cause he did evil, before giving Tamar a child. In Deuteronomy 25:7 there is a law that is called Leverite Law. If the wife doesn’t have a child, the brother must take her as his wife and her first born child is placed under the dead brothers blood line. This way the blood line doesn’t stop. Onan took Tanar as his wife, but didn’t want her child to be under Er, so he used his form of birth control to prevent pregnancy. This was deemed wicked and God had him put to death. Judah was worried since he lost two sons that were married to her so he was sent her to live with her father until Shelah came of age. Shelah came of age and Judah failed to give her as a wife. Tamar heard Judah was going to be in the area, so she dressed like a prostitute and Judah saw her and wanted to have sex. He had no money, so left personal items in pledge. Time passes and Tamar is discovered to be pregnant. Judah is elated as he no longer has to take care of her or give her to his son. She is ordered to be burned to death. She sends word to Judah saying that she has proof who the father is and he wants to see. That is when he learns he is the father and says she is more righteous than he. Tamar has twins, Perez and Zerah. Perez was the first born.
Several things here.
Perez is in both of the bloodlines for Jesus in Matthew 1 and Luke 3, but no mention of Er. Since the father slept with the daughter-in-law, the bloodline is under Judah as the children are illegitimate. If Onan or Shelah had done it, it would be under Er. Luckily this all happened before the Law was given or both would have been put to death. Contrary to some people’s belief, Tamar was not killed once she identified Judah as the father. When Judah declared her as being more righteous than he, she was removed from being immoral and not burned alive.
Bit of history on shrine prostitutes. If a man had sex with her and she had a child, it was thought that the year was going to be bountiful and fruitful. Of course, the child was then sacrificed to Molech as who wants a lot of illegitimate children running around.
When the blood line was tainted like it was between Judah and Tamar, the Torah says the blood line will be cast out of the congregation for 10 generations. Here is where it gets interesting. In Genesis 38, in the Hebrew, if you could 49 letter, you get a ‘B’. 49 more letter and you get a ‘O’. Keep going and you get Boaz, Ruth, Obed, Jesse, and David in chronological order. David was the 10th generation. Strange coincidence that five generations in advance are found in this one chapter that deals with the blood line of Jesus?