Living or visiting Egypt?
In what scenarios does the prohibition apply: Even per the stringent opinion, some Poskim rule the prohibition only applies today when traveling from Eretz Yisrael to Egypt, and not when traveling from another land to Egypt. Other Poskim rule the prohibition only applies to one who moves to Egypt for the sake of living there. However, one may visit/live in Egypt temporarily, such as for business or to learn or teach Torah and the like. Furthermore, if one originally traveled there for a temporary visit/stay and ended up settling there due to financial reasons or other reasons, has not transgressed a prohibition.
Final ruling: Practically, we find that many Gedolei Yisrael and G-d fearing congregations lived in Egypt, including the Rambam, Radbaz, and others, thus relying on one of the Poskim recorded above each according to his reason. Thus, in conclusion, it is permitted to come to Egypt for a temporary stay, such as for business, teaching Torah, tourism, journalism, vacation and any matter of the like. However, one who lives in Eretz Yisrael, may only visit Egypt for a justifiable reason, as applies in all cases that one desires to leave Eretz Yisrael for the Diaspora. Hence, one who is living in Eretz Yisrael is not to set a vacation trip for Egypt unless there is some reason to go specifically there versus Eretz Yisrael, such as sightseeing, or a cheaper bargain and one is in need of a refreshing vacation.
 See Shut Yechaveh Daas 3:81 and Tzitz Eliezer 14:87 for a thorough discussion on this topic
 This prohibition is recorded three times in the Torah: Shemos 14:13; Devarim 17:16; 28:68; Sukkah 51b regarding Bnei Alexadria; Yerushalmi Sukkah 5:1; Mechilta Reb Yishmael Beshalach; Mishneh Torah Melachim 5:7
The reason: This is due to the depravity of Egypt and the fact that Hashem desired to distance us from the Egyptians and learning from their ways. [Rambam Sefer Hamitzvos Mitzvah 46; Sefer Hachinuch Mitzvah 500; Ramban Devarim 17:16]
 Rambam Sefer Hamitzvos Mitzvah 46; Sefer Hachinuch Mitzvah 500;
 Ritva Yuma 38a; Initial explanation in Smag 22; Rabbeinu Bechayeh Devarim 17:16 “It was a temporary prohibition”; Shut Deiy Hasheiv 15
 The reason: The reason is because the prohibition only applied in times that the indigenous Egyptians lived in Egypt, and thus today that the Egyptian people are made up of a multitude of nations due to the mixing of the multitude done by Sancheirev, therefore the prohibition no longer applies. [Smag ibid; opinion in Ritva ibid] Alternatively, the reason is because the prohibition only applied when the Jewish people lived in Eretz Yisrael, while today in exile that the Jewish people are dispersed throughout the lands, there is no difference in law regarding the various areas of the Diaspora. [Ritva ibid] Alternatively, the prohibition only applied in that generation due to the depravity of the Egyptian people, and is no longer relevant today. [Rabbeinu Bechayeh ibid]
 Yireim 309; Smag 227; Hagahos Maimanis Melachim 5:7; Ramban Shemos 1:13 “It is a negative command for all generations”; Kaftor Vaferach 5; Sefer Hachinuch Mitzvah 500; Beis Shmuel E.H. 4:10; It is clear from the Rambam ibid that he holds that the prohibition applies even today. [Aruch Hashulchan Hasid Melachim 74; Tzitz Eliezer ibid; Yechaveh Daas ibid]
 The reason: As the prohibition is dependent on the physical land, and not on the people living there, and so we see in Sukkah ibid that the people of Alexandria were punished even though his occurred after the times of Sancheirev. [Yireim ibid; Semag ibid; Hagahos Maimanis ibid] Alternatively, the reason is because the land of Egypt was not mixed by Sancheirev and hence the indigenous Egyptians live in Egypt until today. [Rosh, brought in Michaber E.H. 4:10]
 Yireim ibid, brought in Ritva ibid; Smag 227; Hagahos Maimanis ibid; opinion brought in Rabbeinu Bechayeh Devarim 17:16; Beis Shmuel 4:10 in name of Mordechai; It is clear from the Rambam ibid that he holds that the prohibition applies even when arriving from other lands. [Aruch Hashulchan Hasid Melachim 74; Tzitz Eliezer ibid; Yechaveh Daas ibid]
 Radbaz 4:73 and on Rambam Melachim 5:7; The Radbaz negates the reason of the Yireim; Aruch Hashulchan Hasid Melachim 74; Tzitz Eliezer 14:87
 Rambam ibid; Sefer Hachinuch ibid
 Radbaz ibid
 Perhaps however the Rambam was forced to live there by the sultan who used his medical services, and hence he had no choice. [Kaftor Vaferach ibid; Radbaz ibid] Some say the Rambam would conclude his letters while living in Egypt with writing “The man who transgresses three negative commands each day” [Kaftor Vaferach ibid in name of grandson of Rambam; However see Yechaveh Daas ibid who brings Sefarim who reject this claim as a libel]
 See Radbaz ibid that he came to live there only temporarily for the sake of studying Torah and teaching it, and afterwards he returned to Yerushalayim
 Yechaveh Daas ibid
 Shevet Halevi 5:173