http://revach.net/article.php?id=1695

Section: Parshas HaShavua   Category: Quick Vort
Parshas Bishalach: How Could The Rambam Live in Mitzrayim?
"Lo Sosifu Lirosom Ad Olam", you will not see the Egyptians again. The Monai HaMitzvos count 3 Issurim which one transgresses if he lives in Mitzrayim. One Lav is this pasuk - "You will not see the Egyptians again". The other 2 are in Sefer Devarim. The Rambam counts this as one of the Lavim in the Torah. As he says, Negative Mitzvah 46: "You may never settle permanently in Egypt again. We are forbidden to return to Egypt in order to settle there. After freeing us from slavery in Egypt, HaShem prohibited us from ever permanently living there again. However, it is permissible to return to Egypt for business or trade."

The question arises, how was the Rambam himself allowed to live in Egypt and transgress the negative commandment which he himself lists?  Some answer, the Issur of living in Mitzrayim is only if one travels there following the same route that the Jews used when leaving Mitzrayim; As the pasuk says, Devarim 17:16 - "You shall never again return that way". However, just to live there is not Assur.  Others answer that the Rambam was an Anus, forced to live there.  He had no choice, since he was the Dr. of the Sultan.

In Sefer Kaftor VaFerach, it is written, the Rambam used to sign his letters - "Moshe Ben Maimon, the one who transgresses 3 Lavim everyday."