Genesis 38:1
And it came to pass at that time, that Judah went down from his brethren, and turned in to a certain Adullamite, whose name was Hirah. And it came to pass at that time, that Judah went down from his brethren, and turned in to a certain Adullamite, whose name was Hirah.
At that time Judah went down from his brethren and turned in to stay with Hirah the Adullamite, and this departure begins the account of the sin of Judah and his family and sets the scene for Tamar's story. What it begins took place after Joseph was sold into Egypt and within the thirteen years before Pharaoh's dreams and Joseph's exaltation to save Israel. The verse stands within Genesis 37-44, the first part of the story of Joseph and his brethren, covering his early life, his brothers' envy, his sale into slavery, his time in Egypt, and God's dealings with him.
The surrounding account presents the sad fruits of Jacob's mistakes as a loving but unwise father whose partiality lavished too little affection on his other sons in comparison with Joseph, the petted child of his old age by his favorite wife, and whose plurality of wives produced jealousies not only between the wives but between the families. From that unwisdom and those marital mistakes came hatred, envy, low moral standards, and crime, so that Joseph's brethren first attempted to slay him but finally sold him as a slave into Egypt. Yet the same history shows that Jacob had still instilled principles of integrity and purity in Joseph, which developed very shortly after his reaching Egypt and on account of which he passed two years in prison, needing the discipline in some way though innocent of any crime. From that prison God called him to the throne of Egypt, and before him his brethren, unconscious to themselves, came and humbly bowed, fulfilling the dreams which had aroused their envy against their brother. The account beginning here was recorded to expose sin so that it may be shunned, not to indulge or excuse it, and it points to God's love, mercy, and power as the remedy for sin.
As part of Joseph's history, the verse illustrates that God may lead a person by a roundabout way while still guiding him to the purpose God intends, overruling human wrath, ambitions, and jealousies to His praise and working out His providence for the true and faithful, even through sorry incidents not necessary to the Joseph narrative. The chapter shows the Lord's displeasure falling on one who shirked his duty as Go'el, or nearest kinsman. Under that law and custom Tamar was less blameworthy, using strategy to claim rights that Judah had fraudulently denied her, and the sons born from the union were counted legitimate. Tamar's conduct with her father-in-law and the birth of Pharez to Tamar, identified as a harlot, place one of that union in Christ's ancestry and show that his human lineage included people with shameful histories marked by moral weakness and sin. That Christ came through a sin-marked human line offers hope to the fallen.