Whether your Bible version reads "coat of many colors" or "richly-ornamented robe," it's clear that the garment Jacob made for Joseph was special. And his twelve brothers were jealous of the special love their father had for him.
So when seventeen-year-old Joseph had a couple of seemingly-prophetic dreams that showed his family bowing down to him, and a teenager's wisdom in sharing it with them, his brothers threw "that dreamer" into a pit or dry cistern out in the wild. Rueben - perhaps weary and wary of further bloodshed after violently avenging his sister Dinah against Shechem's clan - talked them out of killing Joseph outright. He had hoped to come back and rescue Joseph. While Reuben was away, his co-leader in that raid - Judah - had the bright idea to sell Joseph as a slave to a passing Midianite caravan. We don't know who got the money.
Then, painting his torn robe with the blood of a slaughtered goat, they showed it to their father and let him draw the conclusion that Joseph had been killed by a wild animal.
Then Jacob tore his clothes, put on sackcloth and mourned for his son many days. All his sons and daughters came to comfort him, but he refused to be comforted. "No," he said, "in mourning will I go down to the grave to my son." So his father wept for him. Meanwhile, the Midianites sold Joseph in Egypt to Potiphar, one of Pharaoh's officials, the captain of the guard. ~ Genesis 37:34-36
"All his sons ... came to comfort him ...." Even the ones who had conspired to sell their brother as a slave. Swell family, huh?
It gets worse.
Judah, old enough to be married to a Canaanite woman and have two sons of marrying age plus a younger one, lost his firstborn because the son "was wicked in the Lord's sight, and the Lord put him to death." Wanting his firstborn son's clan to continue - Er gave Judah no grandchildren - Judah gave his second son Onan to Er's widow Tamar. Onan didn't mind sleeping with her, but didn't want her to bear his children for Er. And, "what he did was wicked in the Lord's sight, so He put him to death."
Tamar, tired of waiting for the third son to be given to her - even though he was old enough, dressed up like a shrine prostitute with her face veiled. Judah, not recognizing her, negotiated payment for sex with her at one young goat and gave her his seal and cord.
When she became pregnant, Judah was told and - not knowing the child would be his - was ready to burn her alive. She sent the seal and cord to him with the message that they belonged to the father. Judah, with all of the patriarchal wisdom of the head of a kingly tribe, morally decided, "She is more righteous than I, since I wouldn't give her to my son Shelah" and spared her.
She gave birth to twins who - like their grandfather Jacob and great uncle Esau - jockeyed for first place in the womb, and Perez beat Zerah.
So these two chapters come full circle, right back to the theme of sibling rivalry.
But - as LaGard Smith notes in his commentary - Perez would eventually become one of the all-too-human ancestors of the Promised One, the Messiah.
In this study so far, God continues to work His will through these thoroughly messed-up families, through sin and slavery and shame and murder. It's a pattern that continues in the Bible for generations of history, right up to the point where the Promised One is sold for the price of a slave, shamed before those who loved Him, and murdered for the forgiveness of sin.
Can God still work His will through completely flawed people like you and me? In spite of - but still using - our sin, does He even teach us the reason to avoid it by experiencing its consequences - then provide a costly Way of escape from it to buy us back from slavery to it?
Does He see our future as He saw Joseph's, and give us glimpses of what it can be through a dream of revelation that awaits us at the close of scripture?