A further reason is given in today’s Torah reading, which depicts him as the Mashbir, the Food Provider.
The context is a time of drought when food supplies in Egypt were getting dangerously low. Someone had to allocate whatever food there was to ensure that as many people as possible had something to eat.
The policy could easily have been that only the rich and powerful would be fed and the mass of the populace could be left to go hungry. We are reminded that when Marie Antoinette was told that the people of France had no bread, she retorted, “Then let them eat cake!”
Joseph worked out a method whereby everyone would have the chance of getting food.
The Yalkut Shim’oni (to Psalm 80:2) gives the episode a broader spiritual meaning when it says, “Just as Joseph stored up food for the people to eat in time of famine, so God lays up blessings for the righteous to enjoy in the World to Come”.