"Then he said, 'I am God, the God of your father. Do not be afraid to go down to Egypt, for there I will make you into a great nation. I myself will go down with you to Egypt, and I will also bring you up again, and Joseph's hand shall close your eyes.'" (Genesis 46:3–4)
The material in chapter 38 may seem out of place at first, but Judah will play an important role in the nation of Israel moving forward, and we need to find out how he goes from the shrewd, self-serving man of ch. 37 to the responsible man thinking of the grief of his father in ch. 44. Chapter 38 helps to explain this.
We also see an outstanding scriptural illustration of the dangers of Proverbs 18:13 - "If one gives an answer before he hears, it is his folly and shame."
We can come away from Ch. 38 with a greater understanding of who Judah becomes, a greater understanding of the dangers of rendering judgments before we hear the evidence (even in our everyday lives), and a greater hope that if God can work in Judah's life, he can work in ours as well.
Jacob agreed to stay and continue to pasture Laban's flocks and God blessed Jacob in a temporal way in the midst of hardship. That earthly blessing showed Jacob, God's love behind the earthly blessing and pointed him to God's promise of the Gospel.
Human jealousy is an attitude that God specifically forbids. "You shall not covet...anything that is your neighbor's."
Were Joseph's brothers solely responsible for the situation they found themselves in because of Jacob's favoritism? No. Was it understandable that they were jealous of Joseph? Yes.
Does any of that excuse their actions? Not at all, despite what our current society will tell you.
What has God given you that you can (and should) be thankful for?
What has God withheld from you that you should also give God thanks for?