God had told Abraham that his family would spend four generations in Egypt (Genesis 15:13-14). In these chapters we are reading how God brought that prophecy to pass. God had it in His mind to get the family of Israel into Egypt where He would nurse them into becoming a nation. He had a number of chess moves to put together in order to make it happen. And, indeed He was very busy. Think of all of the conditions and people who were affected by the providential manipulation of events that was used in bringing it all to pass. Literally, the whole world went through 7 years of famine so that God could motivate Jacob to pluck up his roots and move to the northeast corner of Africa.
The 7 years of agricultural prosperity must have been spectacularly productive. Not only did the population of Egypt live by eating of the revenue that came from those years, but grain was sold to foreigners for food and to the Egyptians as seed for their fields (Genesis 47:19 & 23). God had surely provided plenty from the period of prosperity for the days of difficulty.
Well, Jacob found out that he could get food from Egypt, so he sent his 10 older sons there to buy grain. Of course, none of them had any idea that they would be buying their grain from Joseph. But, there they were, bowing ignorantly before their little brother (Genesis 42:6) in exact fulfillment of Joseph's dream… which they had despised (Genesis 37:7). With wisdom and (I believe) inspiration, Joseph accused his brothers of espionage in order to discover their hearts and ultimately to bring his dreams to pass.
Joseph detained his brothers for 3 days and then demanded that they bring their other brother back with them upon their return. As they stood and confessed among themselves their guilt concerning Joseph, he had to leave the room because of his own tears as he saw their anguish. He had been through similar distress himself (Genesis 42:21). He knew well how they were feeling. Yet, he kept his identity secret and forced them to leave Simeon behind as insurance of their eventual return to Egypt. Then he sent them back to Canaan with grain... and with the price of the grain hidden in their grain sacks. Of course, rather than being grateful for the refund, their guilty consciences drove them to fear.
When the 9 brothers returned to Israel with their grain, their stories, and the demand concerning Benjamin...and without Simeon, Jacob was devastated. "Benjamin will not go to Egypt!" he insisted indignantly. But, he didn't realize who he was up against. God and Joseph would get their way, despite Jacob's resistance.