This explains fabulously why HKB”H arranged for Yosef to be sold and end up in Mitzrayim. For, we learn from the great Rabbi of Ropshitz, zy”a, in Zera Kodesh (Bo), that the klipah of Mitzrayim opposes Torah she’b’al peh. He supports this assertion with an incredible “remez”: This wicked, corrupt nation is named מצרי"ם, because Torah she’b’al peh begins with an open letter “mem” in its first Mishnah (Berachos 1, 1): "מ'אימתי קורין את שמע בערבית"—and concludes with a closed letter “mem” in its final Mishnah (Oktzin 3, 12): "ה' עוז לעמו יתן ה' יברך את עמו בשלו'ם".
Let us explain this “remez”: When a person opens his mouth to articulate the letter “mem”— מ"ם—he begins by opening his mouth with an open מ' and concludes by closing his mouth with a closed ם', without any interruption between them. This is how a person should study Torah she’b’al peh. He should begin with the open “mem” of "מאימתי" and conclude with the closed “mem” of "בשלום", without any interruptions or distractions in between. Stopping to satisfy bodily needs gives one the strength to study Torah and is an integral part of Torah-study; hence, it is considered as if one is still engaged in Torah-study. This is the “remez” of the name מצרי"ם. It begins with an open “mem” and concludes with a closed “mem”; the three letters between them form the word יצ"ר—yetzer—the negative influence that tries to disrupt the study of Torah. Thus, the name מצרי"ם alludes to the fact that the klipah of Mitzrayim opposes a Jew’s study of Torah she’b’al peh—that begins with an open מ' and concludes with a closed ם'.
With immense joy, this enlightens us as to why Rabeinu HaKadosh—the “nitzotz” of Yaakov Avinu—mentioned Rabbi Eliezer—the gilgul of Reuven—as the first Tanna in the first Mishnah of Torah she’b’al peh. For, it was on account of Reuven that Yosef’s life was spared, and he was sold into slavery and landed in Mitzrayim. There he became the viceroy—“mishneh la’melech”—and became the “merkavah” of the Mishnayos of Torah she’b’al peh—"מרכבת המשנה". In that role, he subjugated the klipah of Mitzrayim that opposes Torah she’b’al peh. Therefore, Rabeinu HaKadosh chose to return the birthright to Reuven by mentioning his gilgul as the first Tanna in the Mishnayos, which are the foundation of Torah she’b’al peh.
This explains fantastically why the reason given in Torah she’b’chsav for the naming of Reuven by Leah is: "ותקרא שמו ראובן כי אמרה כי ראה ה' בעניי"; whereas the novel reason given in Torah she’b’al peh is: "אמרה לאה ראו מה בין בני לבן חמי". In other words, even though Yosef was awarded Reuven’s birthright, nevertheless, he still rescued Yosef by convincing his brothers to throw him into a pit instead of killing him. As we know, he intended to come back and pull Yosef out of the pit.
Let us elaborate. By saving Yosef, the scene was set for Yosef to be sold and end up in Mitzrayim; there, he would subjugate the klipah of Mitzrayim in his role as the “merkavah” of Torah she’b’al peh. For this reason, the sages of Torah she’b’al peh mentioned in the Gemara specifically the reason of: "אמרה לאה ראו מה בין בני לבן חמי". Not only did Reuven not hold a grudge and hate Yosef, but he made every effort to save his life. As a result, it was orchestrated from above for Yosef to subjugate the klipah of Mitzrayim by becoming the “merkavah” of Torah she’b’al peh, as we learned from the passuk: "וירכב אותו במרכבת המשנה אשר לו".