Joseph was betrayed by his brothers, unrighteously thrown in prison, and then forgotten by those he ministered to in prison. The Lord had allowed him to see things to come through dreams and he continued to use this ability when the opportunity arose. Many will hide their candle when persecution arises but Joseph and many others prove that if you use the gifts the Lord has given you God will protect you and make sure His purpose is fulfilled in your life. It was God's purpose that Israel go to Egypt, He had told Abraham that they would be afflicted by Egypt 400 years Gen. 15;13.
Thank about what Joseph had done for the king of Egypt and for the people of Egypt. Without God's warning through Joseph many in Egypt and the surrounding tribes would have died in the seven years of famine. Through Joseph's trading of the grain, Pharaoh became the sole owner of everything in Egypt. If the people had not owned their land and everything else they would have had nothing to sell to get the grain. Before the famine Egypt must have been a very different place. After the famine the king owned everything including the people. At the same time that Joseph was buying everything for Pharaoh, he was GIVING the land of Goshen to his family.
The bible says in Exodus 12;41 that Israel was in Egypt exactly 430 years, in fact it says 430 years to the day. If they were to be afflicted 400 years as the Lord had said, that would mean that 30 short years after they came to Egypt to live, they were enslaved by the Egyptians. This would have been 13 years after Jacob died and likely while Joseph was still alive.
Church, we are to love our enemies, we are to bless those who curse us, do good for those who despitefully use us, ect. but we are not to become unequally yoked with unbelievers because they have a completely different set of rules than we do. Their rules begin and end with them and their best interest. If it is in their best interest to be your friend, they will be your friend. Some of them, not all, will for the right reason turn on you and treat you however is necessary to achieve their goal.
It didn't matter to the Egyptians that many of them would be dead, that their nation would have been severely diminished at a time in history where the strong devoured the weak. It made no difference to this new pharaoh that Joseph had handed his predecessor the entire kingdom through the wisdom that God had given him. Neither did it occur to this new Pharaoh that such a person who talked with God was the greatest treasure in his kingdom. Some unbelievers will recognize and appreciate God and His servants. Some will even be converted like Nebuchadnezzar and some like this Pharaoh and Belshazzar can only think of themselves and their good time.
Think of it like this, some of them are wolves and some of them are sheep in wolves clothing. Our job is to put up with the former while looking for the latter. One note before we leave the Egyptian captivity. Exodus 1;12 is one of my favorite passages of scripture. It really contains no promise or great revelation except for this, that in the midst of bondage and affliction God is able and willing to increase His kingdom and to greve your captors in the process. And sooner or later the bills come due.
"Let your light so shine before men, that they may see your good works, and glorify your Father which is in heaven." Matthew 5:16