There's an explanation of a resolution in the first 4 sections of לא תהי׳ משכלה תשי״ב, which is rather inaccessible for here, so I will try to summarise, and add background and explanation as I've studied the topic, and caution that this is still not sufficient, and encourage those interested to pursue the sources. The (powerful) question asked is actually a question that has been worked on by the Philosophers and Kabbalists, and developed right up until this ma'amar.
In the Moreh Nevuchim I, we learn about the philosophy of essence, which we are told is not composite, and cannot have anything superadded1. He cautions us that Hashem is His Essence (i.e. Himself) and nothing more, and therefore all descriptions in Torah of Him need to be dealt with properly. They are not descriptions of a composite being, but are all Hashem's actions and expression. He talks us through at length how actions can be achieved by Essence2, and do not imply composition in Hashem.
The ma'amar explains that when it comes to His actions and expression, the truth is that Hashem needs us to do the mitzvot. This is the pashut pshat of the Torah - that it is essential to Him that we do the mitzvot, i.e. serve Him3,7.
When it comes to His Essence, we know from the philosophy of essence that essence doesn't need, in that sense of limitation. As the Zohar puts it, Hashem doesn't need a faculty called wisdom to be called Wise4; act wisely. It also says in many places that He doesn't need our mitzvot, they were given for our benefit etc. As the Ramban states in your first quote, Hashem Himself doesn't need the light of the menorah, it is for the sake of our refinement. This is true.
So is this a contradiction? Are we saying that Hashem 'merely' acts in a way that He needs the mitzvot (OP's second quote), but truly doesn't (first quote)? This is the core of the question that's been tackled over the history5. The trajectory has been towards rejecting this, and gradually explain that the truth is indeed that our Divine service is nogeah to Him, Himself.
While He may not need light, what is nogeah to Himself - עצמות ומהות א"ס ב"ה - is that we be refined. The Rebbe arrives at this explanation - having naturally gone with all the build up that came before him - founded on a principle brought from the Ramban's introduction to his perush on Chumash, that the Torah was written in third person, as a narration, rather than from the voice of Moshe or Hashem. The Rebbe explains the Narrator is Hashem Himself, in essence (the whole ma'amar is based around spotting a switch where the Narrator speaks in first person).
The Ramban in your second quote alludes to what's going on. Hashem Himself's true desire is to dwell with us, and this is for His Glory. Therefore, He gave us His precious mitzvot, so we can emulate Him, and be refined, and this is in service of His true desire, and nogeah b'Atzmus; we are nogeah b'Atzmus6. Therefore everything we do refines us and is a true service to Him7. We note that His actions reflect this (are authentic) - as we showed above, the pashut pshat of the Torah is that it is absolutely essential and non-negotiable to Him that we do the mitzvot.
tl;dr: the Rebbe explains a resolution, that would work with Ramban, that the mitzvot refine us, so of course it is for us and our refinement and not His. However, our refinement through the mitzvot, which are essential to Him7, is Hashem's true desire. Therefore it is for Him - no contradition.
Rambam brings the following in the Moreh (3:13), for a little more insight into the depth of this:
״כל פעל יי למענהו״ אפשר שיהיה זה הכינוי שב אל הפעול; ואם יהיה שב אל
הפועל יהיה פרושו למען עצמו ית׳ – רצונו לומר: רצונו שהוא עצמו כמו
שהתבאר בזה המאמר. וכבר בארנו, שעצמו ית׳ יקרא גם כן ׳כבודו׳ באמרו:
״הראני נא את כבודך״ – הנה יהיה גם כן אמרו: ׳כל פעל יי למענהו׳ כאמרו:
״כל הנקרא בשמי ולכבודי בראתיו יצרתיו אף עשיתיו״ – יאמר כל מה שיוחס לי
פעולתו אמנם עשיתיו למען רצוני לא זולת זה
"The Lord hath made everything (la-ma'anehu) for its purpose" (Prov.
16:4). It is possible that the pronoun in la-maanehu refers to the
object; but it can also be considered as agreeing with the subject; in
which case the meaning of the word is, for the sake of Himself, or
His will which is identical with His self [or essence], as has been shown in this treatise. We have also pointed out that His
essence is also called His glory. The words, "The Lord hath made
everything for Himself", express therefore the same idea as the
following verse, "Everything that is called by My name: I have created
it for My Glory, I have formed it; yea, I have made it" (Isa. 43:7);
that is to say, everything that is described as My work has been made
by Me for the sake of My will and for no other purpose.
1. 51-52
2. 54, 57. However, it is best to learn all of I (and similar studies in Chovot Halevavot Shaar Yichud 10 etc. and how it has been absorbed by Kabbalah, e.g. Pardes Rimonim, and Chassidut, e.g. Tanya Sha'ar HaYichud VeHa'emunah), bearing in mind that much is very advanced. The basic facts given are to be accepted if not understood.
3. It is not permitted to ask a servant to do unnecessary service, see Chovot Halevavot 3, Rashi on Vayikra 25:43 (see previous Pasuk, Hashem says explicitly that we His servants), and this is codified in halacha too in Rambam Hilchot Avadim 1:6.
4. Parashat Bo.
5. This discussion revolves around the concepts of וְעָשׂוּ לִי מִקְדָּשׁ וְשָׁכַנְתִּי בְּתוֹכָם Shemot 25:8 (see many commentaries there), and צורך גבוה, such as Sotah 38b and Rashi there, Shabbat 131b, Aruch Hashulchan OC 89:8. See Rabbeinu Bachaye on the OP's same pasuk as Ramban, Shemot 29:46, and Chatam Sofer ad loc, Meshech Chochma Shemot 40:5 et al. Trace the discussion through Ma'arechet HaElokut quoted in Igrot Hakodesh vol 2 p.44, and commentary Pirush Hachayit there. See Avodat Hakodesh (R Meir Ibn Gabbai) Sha'ar Avodah ch 3, Shenei Luchot HaBerit Sha'ar Hagadol, Nefesh HaChaim II 4:16, and all the many Chassidic discussions such as Likutei Torah Balak, the Alter Rebbe, Ma’amarim Avadetem Et Hashem Elokechem, Im Kesef Talve, on parashat Mishpatim, Or HaTorah Mishpatim, pp. 1219, 1666, 3025, and Ve’etchanan p.388, and Ba’ahalotecha p.421, Ma’amarim תרכ״ז, Rebbe Maharash. Hemshech Ayin Bet Ma'amar Vayikra in Ayin Hei vol II, Te’ena U’rena תרע״ז, תש״ם, Zot Torat Ha'elah תרע״ח, תש״ם. Finally, see בשעה שהקדימו תשי״ב. Here is a much lengthier answer going through more detail, with links to works with even more discussion and sources.
6. בשעה שהקדימו תשי״ב explains (see also Alshich on Shir HaShirim 7:11) that dwelling among us is the plan, and it means that He wants a close relationship of intimacy and oneness with us, because His inner inner Ratzon is us. See also second Rashi on Bereshit 1:1.
7. I didn't have room to tackle this here, but see this lengthy answer (refined, with footnotes, here) on a key piece of understanding that the mitzvot are not a means to an end, which is why they are not there to give benefit to Hashem. On the contrary, it is the mitzva He wants, lishma - they are the end themselves, which elevates them infinitely above "benefit".