When I think about chapter 38 of Genesis, I have several thoughts. First, it is interesting to note the paragraph about Onan. I'm not sure if Onan was dealing with jealousy, frustration, or pure hatred for his brother (Er, the firstborn) but he certainly did not want to bless Er posthumously by providing offspring that would be considered Er's as was the tradition at that time. Looking past the tradition itself, this says to me that Onan did not have a good brotherly relationship with Er.
Second, since both Er and Onan were "put to death" while being with the same woman (Tamar), it would seem logical to Judah that the woman was wicked. Thus, Judah decided to keep his third son (Shelah) away from Tamar out of fear that Shelah would also die. As a father myself, I can only imagine the heartache that Judah was experiencing at this time and how much of a parental feeling of protection he must have been feeling over Shelah. But, it is interesting to note had Judah let Shelah marry Tamar, the bloodline of Christ could have been different. I doubt that Shelah would have been directly involved in the bloodline of Christ since he was born from a Canaanite woman but Tamar may not have given birth to Perez who does appear in the bloodline in Matthew 1:3 "Judah the father of Perez and Zerah by Tamar, and Perez the father of Hezron." (ESV)
Third, we see that Tamar gave birth to Perez, who does appear in the bloodline of Christ, and he was fathered by Judah. When I think about this, I can only imagine what type of feelings Judah would be having while seeing his daughter-in-law pregnant with his own offspring. Can you imagine the discussion (or even lack of) that they would be having as a family? It could be that Judah fully embraced Perez and Zerah but I can only think that whenever Judah saw them, he must have been continually reminded of his misadventures in Enaim! I mean, he fully entered into that relationship thinking that Tamar was a temple prostitute. I have to think that this was way outside the bounds of the path that God would have chosen for Judah. But yet, God has used even this event and has turned it for His purposes.
Even after this, Judah is given the blessing from his father Jacob (or Israel).
“Judah, your brothers shall praise you; your hand shall be on the neck of your enemies; your father's sons shall bow down before you. Judah is a lion's cub; from the prey, my son, you have gone up. He stooped down; he crouched as a lion and as a lioness; who dares rouse him? The scepter shall not depart from Judah, nor the ruler's staff from between his feet, until tribute comes to him; and to him shall be the obedience of the peoples. Binding his foal to the vine and his donkey's colt to the choice vine, he has washed his garments in wine and his vesture in the blood of grapes. His eyes are darker than wine, and his teeth whiter than milk." Genesis 49:8-12 (ESV)
It is amazing to me even through all of this, we refer to Jesus as the Lion of Judah. Oh, look how blessed Judah is to not only have the Messiah extend from his bloodline but to even have his name included in an alternative name for Jesus Christ! Wow!
"Then I saw in the right hand of him who was seated on the throne a scroll written within and on the back, sealed with seven seals. And I saw a mighty angel proclaiming with a loud voice, “Who is worthy to open the scroll and break its seals?” And no one in heaven or on earth or under the earth was able to open the scroll or to look into it, and I began to weep loudly because no one was found worthy to open the scroll or to look into it. And one of the elders said to me, “Weep no more; behold, the Lion of the tribe of Judah, the Root of David, has conquered, so that he can open the scroll and its seven seals." Revelations 5:1-5 (ESV)
To sum up, this chapter shows me that God can use our actions to further His purposes. God could have led Judah in a different way to be a part of the bloodline of Christ but even in his failure, Judah was used. If Judah had obeyed God fully and completely, I'm sure that God would have used Judah to bring forth the Messianic bloodline but Judah may have not had to suffer the embarrassment and judgement that he certainly would have had with his relationship with Tamar, Perez, and Zerah.
"Ideally, God’s sovereign power and all-wise and loving purposes are accomplished through obedient servants. But when His children go their own way, God’s infinite power is channeled through unwilling, disobedient men and women, who, in spite of themselves, achieve God’s plans. This they do unknowingly and unpleasantly.
Who would ever have thought that there was any chance of the messianic line continuing through Judah from the initial events of this chapter? Here was Judah, the ancestor of Messiah, taking a Canaanite wife, failing to keep his promise to his daughter-in-law, and propositioning a prostitute, who would just have well been a part of a pagan religious cult? In spite of all of Judah’s sins and in spite of Tamar’s impatience, Perez, the forefather of David and of the Savior, was born. Who but God could have brought such a thing to pass?"