As we have learned on the previous pages of Massekhet Beitza, the passage that forbids work on Yom Tov specifically permits those activities that are essential for food preparation for the holiday (see Sh’mot 12:16). Aside from activities that are directly related to food preparation, like cooking and baking, it is generally accepted that carrying from one place to another is also essential – to bring ingredients or prepared food to the house of a neighbor.
In the Mishna on our daf we learn that Beit Shammai forbids carrying a child, a lulav or a Sefer Torah into the public domain, while Beit Hillel permits them to be moved from one place to another. The Gemara explains that Beit Hillel rules kevan she-hutra le-tzorekh, hutra nami she-lo le-tzorekh – once carrying is permitted for the sake of food preparation on Yom Tov, it is permitted even for reasons aside from that of food preparation. Beit Shammai rejects this line of reasoning.
Even Beit Hillel would agree that there needs to be some purpose in carrying in order for it to be permitted on Yom Tov; lugging around rocks is forbidden even according to Beit Hillel. The purpose can be the needs of a mitzva – like carrying a lulav to the synagogue or a Sefer Torah to study from, or the needs of simhat Yom Tov, enhancing the joyousness of the holiday. Rabbeinu Tam explains that a child can be taken outside because staying at home, or leaving family members behind, would detract from the simhat Yom Tov of both the child and his parents.
Rabbenu Hananel explains that all of the cases in the Mishna are referring to situations where the object needs to be carried for the purpose of a mitzva– the child needs to be circumcised, the lulav to be shaken during Hallel in the synagogue, the Sefer Torah to be read from. Rashi, however, interprets the cases to be any need, even if it is not specifically a mitzva.