On Yom Tov, in contrast to Shabbos, many of the מלאכות, activities, which involve אוכל נפש, the preparation of food, are permissible, as the Torah states, "יאכל לכל נפש הוא לבדו יעשה לכם אך אשר," (שמות י"ב:ט"ז), indicating that only that which is necessary to enable one to eat may be done on Yom Tov. This permission to engage in activities like cooking and baking on Yom Tov applies only in situations where those activities are being done לצורך יום טוב, that is, for the needs of Yom Tov itself. If, however, an individual cooks food on Yom Tov for use on a weekday, all authorities agree that a prohibition has been violated. Rav Chisda, as quoted in the Gemara in Pesachim (דף מ"ו:), claims that this transgression is of a Torah law and consequently, the person is לוקה, that is, he gets lashes. Rabbah, however, differs with Rav Chisda and classifies this Aveirah as a violation MideRabbanan. He says that since (הואיל) guests might unexpectedly arrive on Yom Tov, and this prepared food could be offered food to that company, the earlier act of cooking is viewed as לצורך יו"ט, needed for Yom Tov, and is thus allowed. Rabbah agrees, however, that even though this logic (of הואיל) removes the prohibition which is MideOraisa, the Rabbanan nevertheless forbid a person to cook on Yom Tov for a weekday; the original intent must be for the Yom Tov itself.
All of the above opinions concur, however, that מלאכות related to food preparation (אוכל נפש) done on Yom Tov for Shabbos is permissible according to the Torah. Rabbah is consistent with his reasoning presented above, and explains that this permission granted by the Torah is based upon the logic of הואיל. Rav Chisda, who denies הואיל, suggests simply that MideOraisa, "צרכי שבת נעשין ביו"ט," meaning that one may prepare for Shabbos on Yom Tov. Again, however, everyone agrees that MideRabbanan, it is usually forbidden to cook on Yom Tov for Shabbos. It becomes permissible only if one makes an Eiruv Tavshilin. There is a hint to the concept of Eiruv Tavshilin in this week's Parsha, where the Torah states "את אשר תאפו אפו ואת אשר תבשלו בשלו ," "Bake that which must be baked, and cook that which must be cooked" (שמות ט"ז:כ"ג). The Gemara in Beitzah (דף ט"ו:) derives from here that Eiruv Tavshilin is hinted to in the Torah, as the Posuk is saying that (when Yom Tov falls on Erev Shabbos) one may bake only if something has already been baked, and one may cook only if something has already been cooked.
The Gemara (שם) explains that the Rabbanan deemed it necessary to prohibit cooking on Yom Tov for Shabbos since otherwise people might erroneously conclude that it is permissible to cook on Yom Tov for a weekday as well. Simultaneously, Eiruv Tavshilin was created in order to have something which could serve as a היכר, a reminder, which would help avert this potential mistake in Halacha. If one sets up an Eiruv Tavshilin, the Halacha will view the person as though he is actually beginning the cooking prior to Yom Tov, and is only finishing his preparations on Yom Tov. Consequently, an on-looker will conclude that it is indeed prohibited to initiate cooking on Yom Tov (even) for Shabbos, and certainly to do so on Yom Tov for a weekday is forbidden. This understanding of Eiruv Tavshilin, presented by Rav Ashi in that Gemara (שם), is that it serves to magnify כבוד יו"ט, the honor of Yom Tov, because it protects the sanctity of Yom Tov if people realize that they can not do all activities on Yom Tov. Rava, however, differs, and claims that the Eiruv Tavshilin reinforces כבוד שבת, the honor of Shabbos, because as Rashi (שם בד"ה אמר רבא) explains, it guarantees that while one makes one's Yom Tov preparations on Erev Yom Tov, one will recall to at least begin some preparations for Shabbos as well.
The Rosh (שם פרק ב' סימן א') suggests that there is an important distinction between the above explanations of Rav Ashi and Rava. According to Rava, it would be mandatory to create the Eiruv Tavshilin specifically on Erev Yom Tov, as close to Shabbos as possible, since the goal is to honor the Shabbos. On the other hand, based upon the reasoning that Eiruv Tavshilin exists as a way to honor Yom Tov, it could be prepared several days prior to Yom Tov, and remarkably, an Eiruv Tavshilin which remains left over from one Yom Tov, could be again relied upon for a different Yom Tov. The Shulchan Aruch (אורח חיים סימן תקכ"ז סעיף י"ד) rules that לכתחילה, preferably, a person should always make a new Eiruv Tavshilin on each Erev Yom Tov, but בדיעבד, if he did not, this individual can rely on an Eiruv Tavshilin which remains from a previous Yom Tov.
It is important to understand that Eiruv Tavshilin is an institution constructed by the Rabbanan to remove a potential violation of an איסור which is MideRabbanan. But Eiruv Tavshilin certainly does not circumvent an איסור which is MideOraisa. A person therefore cannot rely upon an Eiruv Tavshilin to cook late on Friday afternoon (which is Yom Tov) at a time when one surely does not anticipate the arrival of hungry guests. Without the presence in such a case of the factor of הואיל, Rabbah, as cited above, would classify cooking late on Friday afternoon for Shabbos as an איסור from the Torah. The Magen Avraham (שם בראש הסימן) says in the name of the Rambam that since we accept Rabbah's opinion as the Halacha, this consideration is very relevantהלכה למעשה , and one would not be able to rely upon one's Eiruv Tavshilin and cook at that time.
The Gemara later in Beitzah (דף י"ז:) quotes a dispute between Beis Shammai and Beis Hillel; Beis Shammai hold that one can bake only if his Eiruv Tavshilin included a baked item, and can cook only if it included a cooked item, and so on. Beis Hillel, however, hold that one may make his Eiruv Tavshilin with a cooked item and then do whatever preparations he must do on Yom Tov for Shabbos. The Shulchan Aruch (שם סעיף ב') writes that preferably, one should prepare both פת, a baked item, and a תבשיל, a cooked item, but בדיעבד only a תבשיל is mandatory. The Vilna Gaon (ביאור הגר"א שם בד"ה ואם) explains that מעיקר הדין, strictly speaking, only a תבשיל is absolutely required for Eiruv Tavshilin. However, מנהג ישראל, the custom, is to prepare both פת and a תבשיל. The Beis Yosef (שם בד"ה בעירוב) interjects in the name of Tosafos that if a person's plans for Yom Tov are solely to cook (not to bake), there is absolutely no necessity to include פת in the Eiruv Tavshilin. Similarly, the Shulchan Aruch remarks (שם סעיף ט"ו) that if one's Eiruv Tavshilin was eaten or lost before he cooked for Shabbos, it is forbidden for him to cook unless a כזית of the food remained. The Magen Avraham (שם ס"ק י"ד) explains that this Halacha about the Eiruv being eaten or lost is referring only to the תבשיל. However, if only the פת was accidentally eaten or lost before one completed his work for Shabbos, one is certainly permitted to perform all necessary Shabbos preparations although only the תבשיל remains in tact.
Even though one must attempt to safeguard the foods used for the Eiruv Tavshilin, the Shulchan Aruch (שם סעיף ט"ז) says that after one has made his Shabbos preparations, he may eat it. The Taz (שם ס"ק י"ד) quotes that the custom of the Maharshal was to use the פת as the second loaf for Lechem Mishneh on Friday night and on Shabbos morning, while at Shalosh Seudos, he would eat the פת. His reasoning was, כיון דמתעביד ביה חדא מצוה ליעבד ביה מצוה אחריתי, since this food was used for one Mitzvah, it should be used for another one.
To insure that every Jew is cognizant of the prohibition of cooking on Yom Tov for a weekday, the Rabbanan established the obligation of making an Eiruv Tavshilin upon each household. If, however, a family mistakenly neglects to prepare an Eiruv Tavshilin, they can rely upon that made by the local rabbi or somebody else. The Gemara in Beitzah (דף ט"ז:) relates a story in which a certain rabbi would publicly proclaim that anyone who did not make an Eiruv Tavshilin may rely on his. The Shulchan Aruch (שם סעיף ז') maintains that a person cannot rely upon the Eiruv Tavshilin made by the גדול העיר, the city's rabbi, if he intentionally did not prepare his own Eiruv Tavshilin. Such an individual is classified as a פושע, a sinner. Similarly, the Be'er Heitev (שם ס"ק ו) writes, based upon another story in that Gemara (שם) about one who didn't make his own Eiruv Tavshilin, that the Eiruv Tavshilin of the גדול העיר assists the forgetful family for only one Yom Tov. However, if this family again forgets to prepare their own Eiruv Tavshilin, on a second Yom Tov, they are considered פושעים and cannot be covered by the rabbi's Eiruv Tavshilin.
The Aruch HaShulchan (שם סעיף י"ח), however, proposes that this Halacha about a פושע is limited to an important and knowledgeable person who was negligent in creating his own Eiruv Tavshilin. He points out that the story in that Gemara (שם) was about a brilliant scholar who used to learn with Shmuel. However, the גדול העיר will certainly have in mind to assist the ordinary, typical Jew who didn't sufficiently exert himself to establish his own personal Eiruv Tavshilin. In addition, the Mishnah Berurah (שם ס"ק כ"ו) suggests that even most פושעים may בדיעבד rely upon a unique approach offered by many Poskim. These Poskim declare that the rabbi can include all the פושעים in his community as part of his Eiruv Tavshilin with the exception of those who have specific intent not to be included in the rabbi's Eiruv Tavshilin. Thus in actuality, just about everyone can be included in the rabbi's Eiruv Tavshilin, although it is still certainly preferable for everyone to make his own.