Pharaoh summoned Yosef from his prison to interpret his dream which neither he nor his wise men were able to explain. After Yosef deciphered the meaning of the strange dream he suggested to Pharaoh that he appoint a wise person to take over the responsibility of the land to provide during the good years for the famine years that follow.
This was a strange and courageous thing for Yosef to do. He had merely been called to interpret the dream and not to advise the king what he should do. What eventually convinced the king to appoint Yosef to this task?
Someone explained this with an interesting tale. In Russia many years ago there were two government officials who were always arguing for supremacy. Each thought that his position was higher. Once they were both coming to the train station and a band was playing patriotic music. Each of the men claimed that it was in his honor that the band had been sent to play. They argued with each other until someone suggested that they ask a poor bystander what he thought. They agreed and approached a disheveled beggar standing nearby to tell them what he thought.
The beggar agreed if they would give him fifty rubbles. They did and then he pointed first to one and then to the other and said, “The band is not playing for you nor for you. It is playing for me so that I can get fifty rubbles and survive”.
That is what Yosef was implying to Pharaoh. Hashem could bring the famine without dreams and without revealing His intentions to anyone. The purpose of the dream and its revelation was so that Yosef could be freed from imprisonment and put in charge. Pharaoh saw his wisdom and appointed him.