B'resheet 40:1-4 Then it came about after these things the cupbearer and the baker for the king of Egypt offended their L-RD, the king of Egypt. And Pharaoh was furious with his two officials, the chief cupbearer and the chief baker. So he put them in confinement in the house of the captain of the bodyguard, in the jail, the same place where Yosef was imprisoned. And the captain of the bodyguard put Yosef in charge of them, and he took care of them; and they were in confinement for some time.
After these things - After Yosef was put into prison these two officials were also thrown into prison.
Yosef in charge of them - Even in prison G-d was with Yosef. Yosef impressed his superiors even in jail and had been given a certain level of responsibility.
B'resheet 40:5-8 Then the cupbearer and the baker for the king of Egypt, who were confined in jail, both had a dream the same night, each man with his own dream and each dream with its own interpretation. When Yosef came to them in the morning and observed them, look, they were dejected. And he asked Pharaoh's officials who were with him in confinement in his master's house, "Why are your faces so sad today?" Then they said to him, "We have had a dream and there is no one to interpret it." Then Yosef said to them, "Do not interpretations belong to G-d? Tell it to me, please."
Had a dream - Dream interpretation was a big thing in Egypt at this time. It was believed by the Egyptians that dreams could tell the future. Yosef correctly gives credit to G-d.
There are two people whom G-d used to interpret dreams in the Bible: Daniel and Yosef. Both were careful not to take credit for themselves but to give credit to G-d for the meaning of the dreams. Both interpreted dreams for pagan kings.
We are warned against listening to ungodly dreamers.
D'Varim (Deuteronomy) 13:1-5 "If a prophet or a dreamer of dreams arises among you and gives you a sign or a wonder, and the sign or the wonder comes true, concerning which he spoke to you, saying,' Let us go after other G-d's (whom you have not known) and let us serve them,' you shall not listen to the words of that prophet or that dreamer of dreams; for the L-RD your G-d is testing you to find out if you love the L-RD your G-d with all your heart and with all your soul. You shall follow the L-RD your G-d and fear Him; and you shall keep His commandments, listen to His voice, serve Him, and cling to Him. But that prophet or that dreamer of dreams shall be put to death, because he has counseled rebellion against the L-RD your G-d who brought you from the land of Egypt and redeemed you from the house of slavery, to seduce you from the way in which the L-RD your G-d commanded you to walk. So you shall purge the evil from among you.
B'resheet 40:9-13 So the chief cupbearer told his dream to Yosef, and said to him, "In my dream, behold, there was a vine in front of me; and on the vine were three branches. And as it was budding, its blossoms came out, and its clusters produced ripe grapes. Now Pharaoh's cup was in my hand; so I took the grapes and squeezed them into Pharaoh's cup, and I put the cup into Pharaoh's hand. Then Yosef said to him, "This is the interpretation of it: the three branches are three days; within three more days Pharaoh will lift up your head and restore you to your office; and you will put Pharaoh's cup into his hand according to your former custom when you were his cupbearer.
The cupbearer had to be completely trusted by pharaoh. He was in the position to slip something into Pharaoh's wine to kill him should he be in allegiance with the enemies of pharaoh.
B'resheet 40:14-15 Only keep me in mind when it goes well with you, and please do me a kindness by mentioning me to Pharaoh, and get me out of this house. For I was in fact kidnapped from the land of the Hebrews, and even here I have done nothing that they should have put me into the dungeon."
The land of the Hebrews - At this time the rest of the world was not referring to the Promised Land as Israel. This is still going on today. Yosef's family had not taken possession of the land yet they were still strangers there. Yosef referring to it as the land of the Hebrews shows that he understood the promise of G-d.
The corresponding letter to this chapter is Tzaddi-righteous and humility.
Here we see Yosef declare he had done nothing to deserve his punishment. Yosef interprets the dream through the help of G-d. "Do not interpretations belong to G-d?
Yosef give his word that he will be restored to his former position and office and asks him to remember him when he is restored.
Yosef and the other two men are also symbolic of Yeshua and the two thieves on the execution stake beside Him long into the future from this time. In this case the good thief declares Yeshua's righteousness.
Luke 23:40-43 "Do you not even fear G-d, since you are under the same sentence of condemnation? "And we indeed justly, for we are receiving what we deserve for our deeds; but this man has done nothing wrong." And he was saying, "Yeshua, remember me when You come in Your kingdom!" And He said to him, "Truly I say to you, today you shall be with Me in Paradise."
Here we not only see the good thief say Yeshua has done no wrong and then he humbles himself and declares that he has done wrong. The thief then asks Yeshua to remember him when he entered his kingdom. This is in contrast to Yosef who asks the cupbearer to remember him when he is returned to his former position in what you could consider a paradise on earth at that time. Yeshua would arise after humbling himself on the execution stake and would later in three days be restored to his former glory above. He will also rule on earth at the start of the third millennium after his death with the one year representing one thousand years to the L-rd.
2 Peter 3:8 But do not let this one fact escape your notice, beloved, that with the L-rd one day is as a thousand years, and a thousand years as one day.