Be careful reading this chapter. This stuff isn't light...
First of all, realize that this one chapter covers a long segment in the life of Judah (Israel's 4th son and the father of the royal tribe of the Messiah). In this chapter Judah finds a wife, has three boys, marries two of them off successively to the same woman and then likewise buries them both in succession, watches his youngest son grow up and finally fathers children by his own daughter-in-law.
"Whoa, slow down," you say? Well. I didn't write the chapter. And, no, it's not part of a pornographic novel or an X-rated comedy act... it's the holy Word of God.
Sometimes I think we actually imagine that we are holier than God or that our standards are higher than His. Don't get me wrong, I myself GREATLY appreciate/prefer couth conversation. In general, I don’t find "bedroom” conversation to be comfortable or appropriate in my milieu. However, it is a dangerous misnomer to assume that refraining from discussions that include such realities (even in a serious context) is somehow a form of spirituality. See, the authors of the Bible explored some of the most embarrassing and even unsophisticated issues of life without any apparent restraint or hesitation (Genesis 38:9). They were respectful, but not shy. This chapter abounds with such matters.
Tamar is the main player in this drama. Having been married to Er (Genesis 38:6-7) and to Onan (Genesis 38:8-10), she remained a childless widow. She waited patiently for Shelah to mature, but Judah still didn't give him to her (because Judah was afraid that the same end would come to him as had come upon his two older brothers). When Judah didn't keep his promise, Tamar disguised herself as a prostitute and deceived him into sleeping with her so she could have his children and fulfill her role as a mother of his continuing line.
When Judah found out that Tamar was pregnant, he knew she had been promiscuous. What he didn't realize was that he was the guilty paramour. Of course, he knew he was guilty of being a whoremonger, but he thought it was unknown. And, he was primarily interested in his reputation (Genesis 38:23), not in genuine righteousness. So, when her misdeed was discovered, he was ready to have her burned alive (Genesis 38:24)... that is, until she exposed him and his guilt, then he was (not surprisingly) quite merciful.
Only God could take another ugly situation in Israel's family and not only give us a little laugh, but also bring joy and continuity to Judah's family. Here is the humor: baby Zarah preceded his twin brother Pharez by sticking his hand out during birth (Genesis 38:28). That'd make any parent chuckle. Of course, Pharez ended up winning the struggle in more ways than one… by becoming one of Jesus' ancestors (Matthew 1:3).