Military reasons
Northern Gaza poses more direct threat - notably in terms of firing rockets at Israeli communities or carrying the attacks, like that of October 7 (see the map below). Indeed, most of the territory on the same longitude as Gaza is the sparsely populated Negev desert - Beersheba being the most populated place with about 200,000 inhabitants. Tel Aviv, Jerusalem and other highly populated towns are to the north of Gaza.
(image source)
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/xVf7s9aim.png)
Likewise, the north of Gaza is densely populated (notably the Gaza City), and likely to contain most of Hamas' infrastructure:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/1KXBveo3m.png)
Humanitarian reasons
Invading from the north also allowed civilians to flee to the south of Gaza, which borders with Egypt. This would enable to those, having Egyptian passports and visas to exit the strip. It would also allowed resupplying the strip via Egypt, rather than via the crossing points in Israel, which are most vulnerable to the attacks - in fact, this is how it was during the first weeks of the war.
Some would also add that this could have allowed potential expulsion of Gazans to Egypt - the idea was publicly discussed by some extreme right wing ministers, but it is not clear whether it had ever affected the military planning.
Political reasons
Invasion of Rafah, particularly the Philadelphi corridor is problematic in view of the relations between Israel and Egypt, which assume demilitarization of the areas near the border, as a guarantee of non-agression by both sides (or being able to detect the preparations for such an aggression well in advance.) Indeed, it took some haggling between Israel and Egypt, before Egypt tacitly accepted that it would not abrogate the peace treaty between the two countries, if Israel invades Rafah (see, e.g., here and here.)