I have always found it interesting that God has His will and we have ours. He gave us free will so that we can make choices, live our lives. But, He also has a will and makes plans. Those plans do affect our lives.
Joseph’s brothers devised a plan to get rid of him. They decided that they did not want him in their lives. Of course, this sounds like a very bad event for Joseph. What ultimately could have ruined his life forever ended up being a good turn of events.
God intervened His will in Jopeph’s life. God had a plan to turn these events into something good. Joseph ended up living the dreams God had given him.
Joseph said to them, “Do not be afraid, for am I in the place of God? But as for you, you meant evil against me; but God meant it for good, in order to bring it about as it is this day, to save many people alive. Now therefore, do not be afraid; I will provide for you and your little ones.” And he comforted them and spoke kindly to them. Genesis 50:19-21 NKJV
God does work in mysterious ways. This is much like when my wife and I lost a newborn son and ended up having a daughter shortly after. Would we have had a daughter if we had not lost our son? We were not planning on having another child at the time. God ended up turning a tragic event (losing our son), into a very good event in having a daughter. Losing our son was hurtful. But, our daughter brought us joy. God worked something evil into something good.