In this week's Parsha, the Torah states, "Six days you shall work and the seventh day shall be sacred for you. It is a complete rest of the Almighty" (Shemot 35:2). Rashi cites the sages that the Torah repeats the prohibition against working on Shabbat as an introduction to the command to build the Mishkan. This is to teach us that working on Shabbat is forbidden even for the great Mitzva of building the holiest of places.
At times a person might make all kinds of calculations about how it is worthwhile to break Torah commandments because his intentions are elevated. He might argue that he isn't doing this for personal gain but for the sake of Heaven. From here we can understand the principle that these calculations are against Hashem's will.
Rabbi Elchonon Wasserman gave a parable that expresses this point. An emperor sent his most trusted advisor to a foreign country on a specific mission. He was told to speak to the king of that country but was warned not to make any bets or wagers. "Remember carefully," the emperor told him, "no matter what the wager is, do not get involved."
When the emperor's advisor was in the midst of his discussion with the foreign king, the king said to him, "I have never seen anyone as hunchbacked as you." "But I am not a hunch back at all," said the puzzled advisor. "I see clearly that you are," the king said. "I'll even make you a wager of a million dollars. Just take off you shirt and undershirt and everyone will see that you are a hunchback."
The advisor was about to enter into the wager with the king, but then remembered the warning of the emperor not to make any wagers. "But this is different," the advisor told himself. "I can't possibly lose on this one. I know that I am not a hunchback and I'm certain that if I were able to consult with the emperor he would allow me to make this wager."
The advisor made the wager and when he undressed in front of the King and in the presence of all those who stood by, the King gave him the million dollars he won.
With great joy the advisor rushed back to the emperor and told him the wonderful news. But instead of being happy, the emperor angrily said to him, "How could you have disobeyed my orders not to make any wagers? you are gravely mistaken, you might have gained one million dollars, but I have just lost ten million dollars. I had a wager with this king that he wouldn't be able to willfully have you undress in front of the members of his court. Your small gain is my great loss."
This, said Rabbi Elchonon Wasserman, is what happens when a person disobeys the commandments of the Torah with calculations that what he is doing is better for the Almighty. The person only thinks there is a gain, but in fact there is a great loss.