The Gemara (Sanhedrin 21b) states: “Rabbi Yitzchak said: Why were the reasons behind the Mitzvot not revealed? Because there were two Mitzvot whose reasons were revealed and one of the greatest of men, King Solomon, failed in them.” This refers to the following two Mitzvot: The Torah (Devarim 17) states regarding a king of Israel, ‘Only that he not have too many horses and that he not return the nation to Egypt in order to multiply his horses.” This means that a Jewish king may not have many horses so that he not transgress the prohibition of returning the nation to Egypt in order to perform business and multiplying his horses. Similarly, the Torah (ibid.) states, “And he may not have too many wives and that his heart not stray.” This refers to the prohibition that a Jewish king may not marry too many wives so that his heart not be led astray from Hashem as a result of his wives.
These two Mitzvot whose reasons were explained explicitly in the Torah were eventually transgressed by King Solomon, who acquired too many horses and married too many wives, for he claimed, “I will have many horses and I will not return the nation to Egypt! I will marry many wives and I will not be led astray from Hashem!” At the end, the verse (Melachim I, Chapter 11) states: “And it was in the old age of Solomon, his wives led his heart astray after other gods and his heart was not complete with Hashem as was the heart of his father, David.” Likewise, he ended up failing in terms of the horses, as the verse states, “And a chariot left Egypt.”
Indeed, even when we search to understand the reasons behind the Mitzvot, this is only because of our endearment of Mitzvah performance and our intense desire to perform the Mitzvot in a beautiful and complete manner. We do not perform the Mitzvot for our own benefit; rather, we have a loftier intention of performing Hashem’s will and carrying out his commandments. Indeed, Rashi (Vayikra 1, 9) comments that our performance of the Mitzvot brings satisfaction to our Father in Heaven.
Similarly, the great Rishon Le’Zion, Moreinu Hagaon Harav Yitzchak Yosef Shlit”a, explains this idea further in his Sefer Ein Yitzchak (Volume 1, page 169) based on the words of the Maharal of Prague (Tiferet Yisrael, Chapter 6) that all of the reasons behind the Mitzvot that we learn about are merely the positive effects that result from our Mitzvah performance but not reasons to perform the Mitzvot. This means that included among the other positive attributes resulting from performing the Mitzvot are the reasons found in the teachings of our Sages and the commentaries, similar to what Maran Ha’Bet Yosef (Yoreh De’ah, Chapter 181) writes that one must seek out the reasons for the Mitzvot as much as possible, however, one should not perform the Mitzvot only because of these reasons. Nevertheless, these reasons are not the roots or basis for the Mitzvot and are merely positive outcomes of the Mitzvah itself.
Summary: One must perform the Mitzvot solely because they are the commandments of Hashem, our father and king, and not because of various reasons quoted by the commentaries. It is nevertheless beneficial to know the reasons behind the Mitzvot so that we may perform them with maximum love and endearment.