Judaism has long rejected the notion that the ends justify the means. One of the most basic of Talmudic rules is that a mitzvah haba b’aveirah, a mitzvah enabled through the commission of sin, is rendered invalid. The third chapter of masechet Sukkah, lulav hagazul, the stolen lulav, gets its name from the fact that a stolen lulav is an invalid lulav and one gains nothing by using one, but may indeed be helping to create a desecration of the name of G-d.
One cannot come closer to G-d by hurting those created in His image. It is bad enough to steal, but to do so in the name of supposedly coming closer to G-d subverts what religion and Torah are all about. One cannot whitewash unethical business practices by giving increased amounts of charity.
Since the ends cannot justify the means, it is rather shocking to come across the teaching of Rav Nachman ben Yitzchak, who taught, “Greater is a sin done lishma, for the sake of heaven, than a mitzvah done shelo lishma, not for the sake of heaven” (Horayot 10b). Can this really be so?
The Gemara explains that this principle has Biblical roots derived from the verse, “Most blessed of the women is Yael, wife of Heber the Kenite, more blessed than the woman in tents” (Shoftim 5:24). As the Gemara explains, Yael had relations with Sisera – a most grievous sin. However, her sole intent was to save the Jewish people by first weakening and then killing Sisera. This act made her more deserving of blessings than the women who dwell in tents, i.e., Sarah, Rivkah, Rachel and Leah.
The Gemara does not explain its rather startling implication that the actions of our Imahot were shelo lishma, not done for the sake of heaven.
Tosafot HaRosh explains that Yael’s intentions were 100% to weaken Sisera, and she had no desire for any sexual pleasure. In fact, the Gemara explains that Yael was repulsed by Sisera, but acted as she did to save the Jewish people. In contrast, the Imahot had relations for “their pleasure” and as such this is considered a mitzvah shelo lishma!
This idea is reflected in Rashi’s interpretation of the verse – one we recite as we prepare for the Yamim Noraim – “Though my father and mother abandon me, the Lord will take me in” (Tehillim 27:10). Rashi explains that when a husband and wife engage in relations, they do so not for the sake of having children, but for the pleasure involved; “and when they are finished, this one turns this way and this one turns that way, and G-d takes the drop [of sperm] and forms the fetus.”
That any personal enjoyment would render a mitzvah shelo lishma is, I am sure, troubling to many and is not a viewpoint shared by all. In his introduction to the Eglei Tal, his classic work on the laws of Shabbat, the Avnei Nezer, the founder of the Sochochev Hasidic dynasty, explains that the “essence of the mitzvah of learning Torah is to be happy and full of joy and derive pleasure from one’s learning. The words of Torah will then be absorbed into one’s body”. When we enjoy a mitzvah, it becomes part of our essence and this, he explains, is the highest form of lishma.
That the appropriateness of an act can be determined by intent means that two people can do the same act yet our assessment of each may be radically different. Such was the case regarding Lot and his daughters. They “intended for the sake of heaven”, hoping to repopulate a world they believed destroyed. Lot, on the other hand, intended to sin. About the daughters, we can apply the verse, “The righteous walk in them”; and about Lot, we can apply the verse, “and the sinners stumble in them”. It is why the Gemara praises Tamar for her efforts to have a child, but has no such praise for Yehuda.
That this concept is potentially most dangerous and open to abuse hardly needs to be said. The Gemara lowers the value of an aveirah lishma somewhat by clarifying that it “only” to be equated with a mitzvah shelo lishma. It is much, much easier to do a mitzvah shelo lishma (probably too much easier) than an aveirah lishma. As the Netziv explains (see here for an elaboration), Yaakov was not punished for tricking Yitzchak as he was purely motivated; it hurt him to have to lie to his father. But he had no such qualms about tricking Eisav, and got some perverse pleasure from doing so. And for that he—and the Jewish people—had to be punished.
Doing a mitzvah shelo lishma is almost always appropriate (see here for some exceptions to the rule), and on rare occasions, an aveirah lishma is the correct approach. Fortunate and blessed are those who are able to do mitzvoth lishma.
 With money being fungible, making it difficult to identify one’s charity dollars with a specific unethical action, this this may not technically be a violation of the principle of mitzvah haba b’aveirah, a mitzvah enabled through commission of sin. Nonetheless, such technicalities are irrelevant and surely impress neither G-d nor man.
 The concept of mitzvah haba b’aveirah seems to apply only to sins between man and man. If the only way to observe one mitzvah between man and G-d is by violating another, so be it. This is based on the principle of aseh docheh lo ta’aseh, a positive command pushes aside a negative one. Thus, one may wear a four-cornered garment made of sha’atnez, a mixture of wool and linen, in order to fulfill the mitzvah of tzitzit. Actively performing mitzvoth expresses love of G-d, whereas awe is demonstrated by refraining from forbidden activities. It is greater to love G-d than to fear Him and thus, a mitzvah aseh can push aside a lo ta’aseh.
 When the three “angels” inquired about Sarah, Avraham told them, “She is in the tent” (Breisheet 18:9). Yitzchak, upon marrying Rivka, “brought her to tent of Sarah, his mother” (Breisheet 24:67) and Lavan, when searching for his stolen terafim, “went from the tent of Rachel to the tent of Leah” (Breisheet 31:33).
 For a rather startling alternate explanation, see Rashi, Nazir 23, s.v.Sarah where he explains that our Imahot had children “shelo lishma” as they were motivated by jealousy, something the Torah specifically mentions regarding Rachel (Breisheet 30:1). We discuss this Rashi here.
 As Lot was drunk and unaware of what was happening, it is unclear why he is considered as intending to sin. The Gemara explains that while the drunken Lot may have been blameless when his eldest daughter slept with him, he should have known not to drink again, lest his younger daughter do the same thing. One is ultimately responsible for the results of one’s carelessness, even if there was no intention to sin.