When the famine was upon the entire land, Yosef opened everything in which there was grain...
The Ohr Hachaim asks a practical question: why was it necessary to open all of the grain storage houses? Why not open only those that were necessary? He had saved grain for seven years, surely only a seventh of them had to be opened.
The Ohr Hachaim explains that his intention was to check all of them in order that there not be any problems with the produce in the future. Imagine they used up one storage house, relying on another one for next year, and when the next year arrives, the stores are wormy. They would have nothing to eat.
Another reason to open all of them is that he spread the granaries around the country, near the cities from where the produce came. This saved people the bother of traveling and prevented people from hoarding. If they knew the supplies were nearby, there would be no reason to hoard.
Also, if the produce were far from the cities, people would feel hungry. Psychologically, a person needs to have his food supply near him. Otherwise, he begins to feel the effects of the hunger, even when his stomach and plate are full. As soon as a person knows that his food is available, the side effects of hunger are alleviated. People aren’t jealous of each other and they are optimistic about the future.