"FOR I SHALL MAKE YOU A GREAT NATION THERE" (Bereishis 46:3)
This teaches that the exile in Egypt was not a random occurence, or for chastisement. It was the "iron furnace" (Dvarim 4:20, Yirmiah 11:4) where the precious metal would become sufficiently refined to be worthy that "you should become My peculiar treasure above all the peoples" (Shmos 19:5).
Egypt was especially planned as a preface to Sinai. But the entire plan was based on the fact that the virtuous Joseph gained almost absolute power over Egypt, and under his wise leadership the "great nation" was enabled to come into existence. -- The Beginning