Some disagreements in the Talmud run throughout Shas of through a particular tractate. The machloket (argument) between R’ Yehuda and R’ Shimon is one such disagreement.
A fundamental argument concerning the liability of one who performs Melachah on Shabbat involves a Melachah she’Einah Tzerichah l’Gufah, a Melachah “that is not needed for itself.” Rebbi Yehudah and Rebbi Shimon argue whether one is Chayav for performing a Melachah that is “not needed for itself.” R’ Yehudah says that one is Chayav, while R’ Shimon says that one is Patur. What exactly is the definition of a Melachah “that is not needed for itself”?
(a) Tosfot (94a, DH Rebbi Shimon Poter) quotes Rashi as saying that a Melachah she’Einah Tzerichah l’Gufah is any Melachah that one does in order to prevent something else from happening, or in order to rectify a wrong that was already done. For example, when a person carries a dead body out of a house on Shabbat, his primary intention is to correct an uncomfortable situation (the dead body being in his house); he does not specifically intend to transport the dead body to Reshut ha’Rabim. He would have preferred that no dead body enter his house in the first place.
Tosfot, however, refutes this explanation. In the case of a curtain that has a wormhole and a person tears the curtain some more above the hole and below the hole in order to mend it neatly, he is Chayav (this is the Melachah of Kore’a, Shabbat 75a). According to Rashi, one should be Patur in such a case. The person tears the curtain only in order to prevent further damage, and he would have preferred that the wormhole not be there in the first place!
(b) Tosfot (ibid.) defines a Melachah she’Einah Tzerichah l’Gufah as any Melachah that is not performed for the same reason for which that Melachah was performed in the Mishkan.
(c) The Rambam (94b) and Ba’al Ha’em’or (106a) write that a Melachah must be performed with the objective for which that activity is normally performed. If one does the Melachah for a purpose other than its normal objective, the act is a Melachah she’Einah Tzerichah l’Gufah. For example, digging a pit in order to use the dirt is a Melachah that is not needed for itself, because, normally, the objective of digging is in order to have a pit, and not to use the dirt, which is a secondary outcome of the digging. In addition, a Melachah performed in order to prevent damage from happening, such as capturing a snake in order to prevent it from causing harm to people, is considered a Melachah that is not needed for itself, because the normal objective of the act of capturing an animal is to use the animal. The same applies to carrying an object into Reshut ha’Rabim in order to keep oneself from becoming soiled. This may be Rashi’s opinion as well, unlike Tosfot’s understanding of Rashi (as mentioned in (a) above). This is why tearing a curtain to repair a wormhole is considered an actual Melachah; the person who tears the curtain is primarily interested in having the curtain torn (the primary effect of the Melachah) and not in a secondary outcome of the tearing.