A commandment has value intrinsically, even without intent.
As was explained, the qualitative difference between good and evil, between commandment and sin, is not determined based on one’s intent.
The levels of intent, with their many differences, determine the “size” of the commandment, its quality and level of connection with the supernal worlds, but not the basic essence of the act as a commandment or as a sin, as holy or as a kelippa.
Every mitzva act, even when executed without any inner substance, creates a reality of holiness.
Its holiness is objective and is derived not only from the intent of the thought.
An act of holiness is like a holy book in a cabinet.
The book does not fulfill any of the commandments written within it, it does not study Torah or ascend to the heavens on its own, but nevertheless, it remains a holy book in an honored place, in a holy place, since it is meant and fit to assist in fulfilling commandments.
A commandment performed without intent lacks the energy of holiness, it lacks the point of connection with supernal existence.
Therefore, it cannot ascend to stand before God, the King.
But the commandment remains a commandment, and even without the intent of holiness, it is an entity of holiness that cannot be erased.
Rabbi Adin Steinsaltz