The last Mishnah in Maseches Makkos states that God wanted to benefit Israel so He gave them many mitzvos.
ר' חנניה בן עקשיה אומר רצה הקב"ה לזכות את ישראל לפיכך הרבה להן תורה ומצות שנ' ה' חפץ למען צדקו יגדיל תורה ויאדיר
Rambam, in his commentary to that Mishnah, explains this to mean that because there are so many mitzvos it is nigh impossible for someone to never fulfill at at least one properly, and by fulfilling even one mitzvah properly one attains Olam Haba. He also references something he explained elsewhere.
מיסודות האמונה בתורה שאם קיים האדם מצוה משלש עשרה ושש מאות מצות כראוי וכהוגן ולא שתף עמה מטרה ממטרות העולם הזה כלל אלא עשאה לשמה מאהבה כמו שבארתי לך הרי הוא זוכה בה לחיי העולם הבא לכן אמר ר' חנניה כי מחמת רבוי המצות אי אפשר שלא יעשה האדם אחת בכל ימי חייו בשלימות ויזכה להשארות הנפש באותו המעשה
R. Kafih in the footnotes cites the Mishnah in Kiddushin (1:10) as the "elsewhere" that Rambam was referring to. That Mishnah states that anyone who does one mitzvah will get rewarded, will get long life, and will inherit the land.
כל העושה מצוה אחת מטיבין לו ומאריכין את ימיו ונוחל את הארץ וכל שאינו עושה מצוה אחת אין מטיבין לו ואין מאריכין את ימיו ואינו נוחל את הארץ
Rambam there explains "doing one mitzvah" as doing an additional mitzvah that tips the balance of merits vs sins, and he explains the reward as occurring in Olam Haba. This implies that by merely doing one mitzvah one would not gain reward in Olam Haba if his sins still outnumber his merits.
רצה באמרו כל העושה מצוה אחת שיעשנה יתירה על זכיותיו שהם כנגד עונותיו כדי שיהיו זכיותיו מרובין על עונותיו במצוה זו ואמרו כל שאינו עושה מצוה אחת כלומר שעונותיו מרובין מזכיותיו ולא עשה מצוה אחת כדי שיהו שקולים אלא נשאר עונותיו מרובין מזכיותיו ואמרו מטיבין לו ומאריכין את ימיו בעולם הבא וענין נוחל את הארץ ארץ החיים כלומר העולם הבא ונבאר את זה בפרק העשירי דסנהדרין
Furthermore, in his introduction to Perek Cheilek (Sanhedrin Chapter 10) Rambam explains that one can only attain Olam Haba if he upholds the 13 principles of faith delineated there.
וכאשר יהיו קיימים לאדם כל היסודות הללו ואמונתו בהם אמתית הרי הוא נכנס בכלל ישראל וחובה לאהבו ולחמול עליו וכל מה שצוה ה' אותנו זה על זה מן האהבה והאחבה ואפילו עשה מה שיכול להיות מן העבירות מחמת תאבתו והתגברות יצרו הרע הרי הוא נענש לפי גודל מריו ויש לו חלק והוא מפושעי ישראל וכאשר יפקפק אדם ביסוד מאלו היסודות הרי זה יצא מן הכלל וכפר בעיקר ונקרא מין ואפיקורוס וקוצץ בנטיעות וחובה לשנותו ולהשמידו ועליו הוא אומר הלא משנאיך ה' אשנא וכו
In sum, we have three differing statements in Rambam's Commentary to Mishnayos on how to attain1 Olam Haba:
- Do any one mitzvah properly (Commentary to Makkos).
- Do an additional mitzvah that leaves one with more merits than sins (Commentary to Kiddushin).
- Uphold the 13 principles of faith (Commentary to Sanhedrin).
How are these three statements to be reconciled?
1. This might not be so precise because the first and third statements seem to be discussing how to attain Olam Haba in the first place, while the second statement seems to be referring to increasing one's reward once he already has Olam Haba.