As for you, you meant evil against me, but God meant it for good, to bring it about that many people should be kept alive, as they are today.Genesis 50:20 esv
The trials God allows us to endure are never purposeless. He always has an intention for what He allows you to endure. Everything God sent Joseph through was to make Him a stronger leader. God is preparing you as well!