First I will attempt to address the contradiction with the verses, as Rambam could theoretical change his opinion, or modify his view, but he cannot disagree with a verse. Therefore, an answer for the contradiction to the verse is more pressing.
In summary two answers (discussed more below) are as follows:
- In Yesodei HaTorah he says that miracles arent the reason to believe that someone is a prophet. The verse never says that the miracle was a reason to believe Moshe was a prophet. Rather, it was meant to show that Moshe was the rightful leader.
- While a miracle is insufficient proof to believe someone is a prophet (or leader), it is a good reason to doubt someone. By process of elimination, Moshe was believed; not by dint of the miracle itself, but because Korah was disqualified, and he was left.
First Answer: Let us carefully read his words in Yeosodei HaTorah. He says that the point of miracles was not as the ultimate confirmation, but to achieve some end, לפי הצורך עשאם. What then was the point of the Earth swallowing Korah et al. at all? He himself describes there כפרו בו עדת קרח בלעה אותן הארץ, that when they denied Moshe, that the solution was for the Earth to swallow them. So, Rambam himself in Yesodei HaTorah acknowledges that the event was meant to solve the problem of denial of Moshe; likely, by bolstering his credentials.
The question is, what about Moshe were they denying. It appears form the simple reading of the verses (or at least the verses could be understood), that Korah wasn't making a theological point against the Torah, its way, a particular prophecy of Moshe, or even against Moshe's status as a prophet. After all, they already experienced Sinai, at which Moshe pretty clearly played a central role (See Yesodei HaTorah 8:1-2), rather, it was a fight over who the leader of the people was supposed to be.[i]
Rambam's point is Hilkhot Yesodei HaTorah (ch. 8) is that belief in a prophet and his prophecy, cannot be justified by a supernatural event alone. After all, maybe its just a magic trick. However, that is not what took place with the Korah affair. Prophet Moshe and his Torah were never under assault; it was Moshe Rabbenu; Moshe the leader, who was under assault, and it was to support his role as leader; not his status as a prophet, that the ground swallowed Korah. Note Moshe's words: ויאמֶר משֶׁה בְּזֹאת תֵּדְעוּן כִּי יְדֹוָד שְׁלָחַנִי לַעֲשׂוֹת אֵתו כָּל הַמַּעֲשִׂים הָאֵלֶּה כִּי לֹא מִלִּבִּי. The event is supposed to be evidence for Moshe's activities; no mention is made of proof for his statements, prophecies, or the Torat Moshe which he preached. The other verses imply this or can be read this way as well: לֹא יְדֹוָד שְׁלָחָנִי vs. כִּי נִאֲצוּ הָאֲנָשִׁים הָאֵלֶּה אֶת יְדֹוָד. Neither one focuses on the nature of the religion or prophecy or its teaching, but whether Moshe is the one sent by God, or whether Korah is a rabble rousing rebel. Accordingly, there is no contradiction between Yesodei HaTorah and the verse.
Second Answer: There is another reason which it may not be a contradiction, which is that in the Korah affair, there seems to have been two options; Moshe, or Korah. While a miracle is not sufficient proof to belief a supernatural claim; that God communicated a message to someone, and that we must act accordingly, in the case of Moshe vs. Korah, where Korah was swallowed by the ground, it is safe to assume that he is not the leader / prophet (even though a miracle isn't a positive proof). Accordingly, by process of elimination, Moshe was considered the messenger. A miracle isn't good proof in a vacuum, but here is was just meant to disqualify Korah.
Regarding the PHM to Sanhedrin. We can suggest the fact that the Torah was given to the prophet Moshe is taken for granted. However, who says Moshe didn't tamper with things, adding or taking away. The focus of the ikkar isn't that Moshe was a prophet, or that he received the Torah, but rather that the whole Torah is holy, and doesn't have less important additions by anyone; namely Moshe. Note his words:
שנאמין שכל התורה הזו הנמצאת בידינו היום הזה היא התורה שניתנה למשה
That is, the fact that Moshe received the Torah is taken for granted. The point is, as he goes on to say that Moshe faithfully transcribed the whole thing:
ושהוא במעלת לבלר שקורין לפניו והוא כותב כולה...וזהו ענין אין תורה מן השמים, אמרו שהוא האומר שכל התורה כולה מפי הקדוש ברוך הוא חוץ מפסוק אחד שלא אמרו הקדוש ברוך הוא אלא משה מפי עצמו...והוא רק מוביל שליחות נאמן במה שהביא, והדבור המורה על היסוד הזה השמיני הוא אמרו בזאת תדעון כי ה' שלחני וכו' כי לא מלבי
Accordingly, this doesn't run afoul of his statement in Yesodei HaTorah, since in PHM the issue is not whether Moshe was a prophet, but whether he added less holy parts to the Torah. Regarding this issue, Rambam invokes the Korah incident. Moshe declares that his actions as a leader have been vindicated by the earth swallowing Korah. This credibility that he gained should be sufficient to quiet baseless conspiracies that he tampered with the Torah. This is different from establishing him as a prophet in the first place, or the Torah as true in the first place. Those monumental claims require a higher degree of proof.
[i] Although admittedly, Moshe was commanded (Exodus 28:1) to designate Aharon's sons as the priests; not Korah, and Korah clearly implies (Numbers 16:10) that this was of Moshe's initiative , his point wasn't that Moshe wasn't a Navi in general but that he shouldn't be in charge. He didn't care about the nature of the prophecy, but about the conclusion; who was in charge.