OPINIONS: In the Mishnah, Beis Hillel permits carrying a child, Lulav, or Sefer Torah into Reshus ha'Rabim on Yom Tov because of the principle of "Mitoch." "Mitoch" states that since a Melachah is permitted by the Torah on Yom Tov for the sake of food preparation, that Melachah is permitted even for matters unrelated to food preparation. What is the extent of the application of this principle?
(a) RASHI (DH Ela) says that since Beis Hillel maintains that the prohibition of Hotza'ah, carrying into Reshus ha'Rabim, applies to Yom Tov in principle and is permitted only because of "Mitoch," there remains an Isur d'Rabanan of carrying non-essential items (such as stones) on Yom Tov. Rashi's words imply that even carrying stones into Reshus ha'Rabim is prohibited only mid'Rabanan.
TOSFOS (DH Hachi Garsinan) points out that the text of the common edition of the Gemara (in the days of Tosfos, in contrast to the text of our edition) reads that since Hotza'ah is prohibited on Yom Tov and the only allowance is because of "Mitoch," one is "Chayav" (mid'Oraisa) for carrying stones into Reshus ha'Rabim (and it is not merely an Isur d'Rabanan). Tosfos asserts that Rashi intentionally emended this Girsa because he maintained that once "Mitoch" applies one will not be Chayav for carrying stones into Reshus ha'Rabim on Yom Tov; it is prohibited only mid'Rabanan, even though the act is done for no purpose. According to Rashi, "Mitoch" permits doing the Melachah under all circumstances.
However, how does Rashi understand the Gemara later (21a, and in Pesachim 46b) which states that one who bakes on Yom Tov for the weekday is Chayav Malkus? Why should he be punished with Malkus if the principle of "Mitoch" permits baking on Yom Tov under all circumstances?
The RAN answers that it is true that Rashi does not require that the Melachah be done for a purpose necessary on Yom Tov in order to be permitted. However, doing the Melachah because one specifically needs it for the next day is worse than doing it on Yom Tov with no need for it whatsoever, and thus he is Chayav. (The RAN asserts that the RIF agrees with the view of Rashi, while the ROSH understands that the Rif agrees with TOSFOS.)
(b) TOSFOS and most other Rishonim disagree with Rashi and maintain that the principle of "Mitoch" permits a Melachah on Yom Tov only when there is a need for it on Yom Tov (for example, one enjoys doing the act and benefits from it on Yom Tov, such as taking a stroll outside while carrying one's child, or because one fulfills a Mitzvah of Yom Tov with that act, such as carrying a Lulav or a Sefer Torah).
(c) RABEINU CHANANEL (on the Mishnah) says that the Mishnah gives the specific examples of carrying a child, Lulav, and Sefer Torah, because all three are objects with which a Mitzvah is performed (a Lulav on Sukos, a Sefer Torah from which to read, and a child on whom Bris Milah must be performed). Tosfos understands that Rabeinu Chananel means that "Mitoch" permits only an act of Melachah which constitutes a Mitzvah which must be performed on that day (such as Milah), but not an act of Melachah which fulfills a Mitzvah which does not need to be performed specifically on that day (such as carrying a child while one takes a stroll).
(It is possible that Rabeinu Chananel agrees with Tosfos that all types of pleasurable acts on Yom Tov are included in the allowance of "Mitoch." Rabeinu Chananel merely adds that "Mitoch" applies even to the performance of Mitzvos from which one derives no physical pleasure, as long as the Mitzvah is one that must be done on that day.)
(d) The RAMBAM (Hilchos Yom Tov 1:4) writes that "Mitoch" applies to only two Melachos: Hotza'ah and Hav'arah (carrying into Reshus ha'Rabim and kindling a flame). Only these two Melachos may be performed for purposes other than food preparation. All other Melachos which are permitted are permitted only for the sake of food preparation.
(It is possible that the Rambam does not mean that these two Melachos are permitted because of the principle of "Mitoch." Rather, the Rambam's intention may be to rule like the opinion in the Gemara here which suggests that "Ein Hotza'ah b'Yom Tov" -- there is no prohibition whatsoever of Hotza'ah (and Hav'arah, see Pesachim 5b) on Yom Tov. The Rambam merely borrows the term "Mitoch" from the Gemara, but the Heter is not because of the principle of "Mitoch" but because there is no prohibition at all on Yom Tov. (We find that the Rambam occasionally borrows terms from the Gemara and uses them in ways different from the Gemara; see, for example, Hilchos Isurei Bi'ah 1:3.))
This way of understanding the Rambam is advantageous, because if the Rambam rules like the opinion in the Gemara which espouses the principle of "Mitoch," then why does the Rambam limit the allowance to Hotza'ah and Hav'arah? The Gemara says that according to the opinion that permits Melachos because of "Mitoch," the principle of "Mitoch" applies to the Melachos of Bishul and Shechitah (as well as Hotza'ah and Hav'arah) and permits them even when not done for the needs of Yom Tov. If the Rambam does not rule like this opinion, then it makes sense why he does not include Bishul and Shechitah in his list of Melachos that are permitted on Yom Tov even when not done for the sake of food preparation.
HALACHAH: The SHULCHAN ARUCH (OC 518:1) mentions only that Hotza'ah not needed for Yom Tov is permitted. The REMA adds that it is permitted because it is an act that provides pleasure on Yom Tov, as Tosfos (b) writes. The MISHNAH BERURAH (518:1) asserts that "Mitoch" applies not only to Hotza'ah but to all Melachos that are permitted for food preparation on Yom Tov (Hotza'ah, Hav'arah, Shechitah, and Bishul/Afiyah); since they are permitted for food preparation, they are also permitted when done for purposes other than food preparation.