The Holy Reb Yisrael of Ruzhin said:
“The Rambam came from the house of Dovid and wished to be Moshiach. He therefore wrote a work of Halachic decisions encompassing even laws applicable only at the Redemption which would have been accepted by all. Since, however, the world was not ready, hasagos (objections) to his works were made.” (Ner Yisrael – Ruzhin vol. 2 p. 191; See the Rebbe’s handwritten response to this teaching appears in From the Rebbe’s Pen on p. 6 of this issue.)
***
The Rebbe Melech HaMoshiach spoke on this topic as well (Parshas Shemos 5752):
“The Rambam’s spiritual service involved giving Jews, in Egypt, in the night of exile, a foretaste of the Redemption:
He lived in the land of Egypt and it was there that he composed his magnum opus, the Mishneh Torah. [which] was composed since due to the difficulties of exile, the Jews were unable to derive halachic rulings from the Talmud and needed an auxiliary source. Nevertheless, the text that the Rambam composed gave the Jews a foretaste of the Redemption. This is reflected in the fact that it includes laws which will only be relevant in the Era of the Redemption when the Beis HaMikdash will be rebuilt, especially the conclusion of the text which focuses directly on Moshiach.
This is also hinted in his name which makes up the phrase ‘R’vos Mofsai B’Eretz Mitzrayim’ ‘I will multiply My wonders — even — in the land of Egypt.’”