When the butler had returned to work for Pharaoh he had told him of Joseph and how he had helped him understand his dreams. Surely enough Pharaoh had his own dreams that he couldn't understand.
Pharaoh had summoned Joseph and told him of his dream. Joseph had told Pharaoh what his dream had meant, that there would be 7 good years of crops then 7 bad years, so they should put some of the harvest aside. Because of this Pharaoh had made Joseph his second in command.
When the 7 bad years of crops came Josephs 11 brothers were starving so they went on their way to Egypt to see if they could beg for food.
Once the brothers arrived in Egypt they went to the house of Pharaoh and when they saw Joseph they didn't recognize him so they begged and begged his to take pity on them and give them some food. Joseph knowing that it was them decided to give them a little payback and he put a gold cup in the youngest brother Benjamin's sack of grain.
Then Joseph accused Benjamin of stealing his golden cup and was about to put him in jail but the brothers begged him to take pity on Benjamin
Then just as the brothers were about to give up Joseph revealed that it was actually him and they all rejoiced that their brother wasn't dead.