Parshas Terumah begins with Hashem informing Moshe to tell the Bnei Yisrael to take for Him (Hashem) terumah from anyone whose heart desires to do so. Rashi says that the money must be given lishmah – for the sake of giving to Hashem.
Many meforshim were bothered by the following point and questions: we know that there is a machlokes in the Gemara whether mitzvos require kavanah (see Rosh Hashanah 28a). According to the opinion that mitzvos are not required to be performed with kavanah, why does this mitzvah of giving to the Mishkan require kavanah that it be given lishmah? Additionally, even the dissenting opinion that requires kavanah in the performance of mitzvos agrees that for the mitzvah of tzedakah one does not need to have kavanah to fulfill the mitzvah. For example, if one drops money that ends up in a poor man’s hands he has fulfilled the mitzvah of tzedakah – without even knowing it. So why, regarding the mitzvah of donating to the Mishkan, does the pasuk require lishmah?
Some Acharonim differentiated between kavanah and lishmah. In this view, kavanah is the intention to perform a mitzvah and that the person wants to fulfill his obligation. Lishmah is the act of doing the mitzvah for the correct intentions. Although a mitzvah may not require kavanah, it may nevertheless require lishmah.
Perhaps we can answer the second question. The opinion that requires kavanah agrees that it is not required regarding the mitzvah of giving tzedakah. However, the mitzvah of donating to the Mishkan differs from the general mitzvah of tzedakah. The purpose of the mitzvah of giving tzedakah is that the poor man will have money. Once that is accomplished, the mitzvah is fulfilled. Thus, even if one does not have kavanah to perform the mitzvah, once its purpose is accomplished he has fulfilled his obligation.
But the purpose of the mitzvah of donating to the Mishkan was not so the Mishkan has enough money. Hashem would ensure that the Mishkan has enough money even without this donation. The purpose of this mitzvah was to give us the opportunity to give toward the Mishkan. In such a scenario the opinion requiring kavanah in the performance of mitzvos requires that one have kavanah.
Another mitzvah whereby the opinion requiring kavanah is in agreement with the view that one can fulfill a mitzvah without having kavanah is the mitzvah of p’ru u’revu (bearing offspring). This mitzvah is accomplished when one brings children into the world. Thus, even if one does not have kavanah when performing this mitzvah, he will have fulfilled his obligation.
In order to answer the original question, I believe that we need to understand the opinion that does not generally require kavanah. The underlying machlokes as to whether mitzvos require kavanah is based on what makes a mitzvah. There is no dispute that a transgression has occurred (albeit b’shogeig) when one eats a forbidden food. Why? Because once the Torah forbade the eating of pig, it is forbidden to eat pigs. We need not have kavanah to render a pig a pig; it exists as a pig without our intentions. Consequently, when one eats a pig he has transgressed.
Similarly, regarding mitzvos, what makes the act of shaking a lulav a mitzvah? It is not an existing item; rather, it is a palm branch – not a mitzvah. The opinion requiring mitzvos to be performed with kavanah holds this way because in order to turn a palm branch into a mitzvah, one must intend to use it for the purpose of fulfilling a mitzvah.
The opinion not requiring that mitzvos be performed with kavanah follows this logic: once Hashem commands us to do something it becomes a reality. For instance, palm branches are now items of mitzvos – even without our intention to have it this way. Accordingly, if one shakes a lulav without intending to use it for the purpose of fulfilling a mitzvah he has, according to this opinion, fulfilled his obligation.