The Gemara in Masechet Sota indicates how clever Yosef was in his dealings with Pharoah. Although their relationship began on the right foot, Yosef clearly understood with whom he was dealing.
He caught Pharoah at a weak moment when he realized that the king knew all of the languages of the world except for Hebrew. The king made Yosef swear that he would not reveal this lack of knowledge to anyone.
Seventeen years later, when Yakov passed away, Yosef used this oath to his advantage. He told Pharoah that his father made him swear that he would be buried in Eretz Yisrael. When the king was hesitant to grant Yosef’s wish regarding his father’s burial, he was reminded of their earlier oath.
Yosef told Pharoah that if he does not need to honor his father’s oath, he, likewise does not need to honor his oath to the king. And this is the reason why they were able to give Yakov a proper burial in the Cave of Machpeilah.
Yosef was teaching us that you need to understand with whom you are dealing. Sometimes it becomes necessary to outsmart the foxes. And there are many foxes out there!