After all the hardships that Yosef caused his brothers he finally admits to them who he is. He knew that they would now fear that he would take revenge upon them for having sold him into slavery. Instead, Yosef tells them not to worry. He forgives them. In fact he says you have done me a favor. It was really Hashem’s will that I end up in Egypt. He declares to them KI LEMICHYA SHELACHANI ELOKIM LIFNECHEM, “for it was to be a provider that Hashem sent me before you.” (Gen. 45:5) What he was saying is that he was sent to provide food for everyone during the years of famine.
Yosef could have taken out all his anger that he experienced during so many years that he was in Egypt. He would have been justified in the eyes of his brothers if he did take revenge upon them. He was, however, a magnanimous person and found a way to turn the entire episode around so that their terrible act really seems like a favor.
There was also another advantage in Yosef being in Egypt. Hashem had prophesied to Avraham that his descendents would be living in Galut in a strange land. They could have come to this foreign land through war as slaves or through other tragedies. Instead, now that Yosef was such a powerful person in this land, Yaakov was able to come with dignity and given great respect.
All this shows us that we may find ourselves in a difficult position but we must never despair. We should always look at the bright side and realize that things could turn out for the best. Have faith and patience.