PREPARING ON YOM TOV RISHON FOR YOM TOV SHENI [Yom Tov: Hachanah: for Yom Tov Sheni]
Gemara
(Rav Chisda): If one bakes on Yom Tov for the sake of a weekday, he is lashed;
He does not exempt Ho'il (since) if guests would come he could serve the food to them [so it turns out that he cooked for consumption on Yom Tov].
(Rabah): He is not lashed, due to Ho'il.
46b - Question (Rabah, against Rav Chisda): You do not say Ho'il. How may we cook on Yom Tov for Shabbos [when Yom Tov is on Erev Shabbos]?
Answer (Rav Chisda): It is permitted through Eruv Tavshilin. (One begins preparing for Shabbos before Yom Tov, and may prepare more on Yom Tov.)
Question (Rabah): Eruv Tavshilin (mid'Rabanan) cannot permit an Isur Torah!
Answer (Rav Chisda): Mid'Oraisa, one may cook on Yom Tov for Shabbos. Chachamim decreed, lest people come to cook on Yom Tov for the sake of a weekday;
Chachamim required Eruv Tavshilin to remind people that one may not cook freely on Yom Tov for the sake of other days.
Rishonim
Rambam (Hilchos Yom Tov 1:9): One may not bake or cook on Yom Tov what he will eat during the week. Melachah for the sake of food is permitted only for what he will eat that day of Yom Tov. If one made food for Yom Tov, and there was left over, he may eat it on a weekday.
Question: Since we forbid Hachanah mid'Oraisa like Rabah, how can Eruv Tavshilin permit preparing for Shabbos on Yom Tov?
Answer #1 (Ran 1b DH v'Idach Shnei): Mid'Oraisa, it is permitted to cook on Yom Tov for Shabbos, Ho'il guests might come and eat the food on Yom Tov.
Question: Since we say Ho'il, how is Hachanah forbidden?
Answer (Ran ibid.): Hachanah applies to preparation bi'Yedei Shamayim, such as an egg [laid on Shabbos or Yom Tov].
Answer #2 (Hagahos Ashri 1:1 DH Aval): Hachanah applies only to something that was not around at all, such as an egg. It does not apply to food that merely needed to be fixed (i.e. cooked).
Ran (9b DH u'Miha): Shabbos is Nidcheh (pushed aside) for Piku'ach Nefesh. It is not totally permitted. Therefore, the Torah forbids doing a larger amount than is needed. The Torah permitted Melachah of Ochel Nefesh on Yom Tov, even if it was possible from Erev Yom Tov. We permit more than is needed, as long as it is one exertion. Also, Chachamim understood that "Ach Asher Ye'achel l'Chol Nefesh" does not obligate one to weigh and be precise to cook only what is needed. On Shabbos, the Melachah is intrinsically forbidden (just Piku'ach Nefesh overrides), so also the addition is forbidden mid'Oraisa, and nothing overrides it.
Poskim
Shulchan Aruch (503:1): It is forbidden to bake, cook or slaughter on Yom Tov for the sake of the next day, even if the next day is Shabbos or Yom Tov, even if it is the second day of Rosh Hashanah.
Magen Avraham (1): The two days of Rosh Hashanah are like one day to be stringent, but not to be lenient. However, in Siman 416:2, we disqualify an Eruv [eaten on Yom Tov Rishon] for Yom Tov Sheni of Galus. The Magid Mishneh, Rashba and Rambam say that if it was eaten on the first day of Rosh Hashanah, he may rely on it on the second day, for they are one Kedushah. This is a leniency! I answer that the first day is primary, therefore one may not cook on it for Yom Tov Sheni, for he prepares on Yom Tov for a weekday. There, in any case the second day is Chol, and he does not need an Eruv.
Gra (DH v'Afilu): Mid'Oraisa, Yom Tov is only one day. Regarding [burial of] a Mes, Yom Tov Sheni is like Chol even for Rosh Hashanah. We consider the two days of Rosh Hashanah to be one Kedushah only to be stringent, e.g. an egg [laid on the first day is forbidden even on the second]. This is because sometimes they treated both days with Kedushah, i.e. when witnesses [who saw the new moon] came after the time for Minchah, i.e. due to Safek. (Initially they could not do Melachah on the first day, lest witnesses come.) In most years, witnesses came before Minchah, so only the first day was Kodesh. All the more so, after R. Yochanan ben Zakai's enactment, the first day is always Kodesh. Rashi and the Ra'avad (Hilchos Eruvin 8:8) say so. The Rambam holds that they have one Kedushah even to be lenient. The Magid Mishneh says that the Rashba and R. Pinchas ha'Levi agree.
Mishnah Berurah (1): Even something that is only toil, and not Melachah, such as washing bowls, or bringing wine on Yom Tov Rishon for Yom Tov Sheni, is forbidden.
Kaf ha'Chayim (1): One may tell a Nochri to do something for the sake of Yom Tov Sheni if it is not a Melachah.
Shulchan Aruch (528:1): If Yom Tov is on Erev Shabbos, one may not make an Eruv Techumim (Rema - even if he made an Eruv Tavshilin).
Magen Avraham (2): This is because Eruv Tavshilin permits only what is needed for needs of the meal.
R. Akiva Eiger: I would say differently, that it is because Eruv Tavshilin permits only what is permitted on Yom Tov for Yom Tov, to do it for Shabbos. Also, it must be possible that it will be for the sake of Yom Tov, if guests will come. Eruv Techumim cannot permit Yom Tov itself, for one must place it Erev Yom Tov. Also, the act of making an Eruv is not for the sake of today. I support this from Beitzah 22a, which says "Hatmanah (wrapping food to keep it hot) is different, for it is evidently for the sake of Shabbos." We hold that Hatmanah is permitted, for it is not totally evident, but Eruv is clearly for Shabbos.
Rema (667:1): One may not prepare on Yom Tov (Shemini Atzeres) for the night of Yom Tov (Simchas Torah).
Sha'arei Teshuvah (1): The Magen Avraham (514:15) forbids setting up wax candles for the sake of the night.
Mishnah Berurah (5): Simchah Torah is Safek Chol. Perhaps Yom Tov prepares for Chol! In pressed circumstances, if one will not be able to find wine easily at night, one may bring wine or water on Yom Tov Rishon for the Sheni. He must bring it when enough time remains in the day so it is not evident that it is for the sake of the night. Also, he should not carry like he does during the week, rather, with a Shinuy (deviation). There is no proof to permit for a weekday. Perhaps it is permitted only for the sake of a Mitzvah. This is why one may not set beds on Shabbos for the sake of Chol (Shabbos 113a).
Rema (ibid.): Therefore, one may not erect tables and benches [that were in the Sukah] in the house for the sake of the night, for this is preparation.
Magen Avraham (3): Maharil says "if one takes a tabletop that one sets on legs and removes it whenever he wants, one may not set it on its legs in the house, for this is preparation for Yom Tov Sheni. Rather, he leaves them dissembled, and arranges them at night." This connotes that one may stand up tables in the house. Also 666:1 connotes like this. Hagahos Maimoniyos and Hagahos Minhagim forbid setting up tables and benches in the house for the sake of the night. It seems that they forbid only arranging them, but one may stand them up, for Kevod Yom Tov. Other preparations are forbidden. Minhagim forbids bringing wine on Yom Tov Rishon for Yom Tov Sheni. One may not roll a Sefer Torah on Shabbos to the Parshah that will be read [tomorrow] on Yom Tov.
R. Akiva Eiger: This implies that one may roll on Yom Tov for the sake of Shabbos, through Eruv Tavshilin. See Magen Avraham (528:2, brought above, who forbids).
Kaf ha'Chayim (12): Similarly, one may not prepare a Sefer Torah on Yom Tov for Shabbos. Eruv Tavshilin does not help for this (Machazik Berachah).
Mishnah Berurah (5): Also, one may not roll a Sefer Torah on Yom Tov to the Parshah that will be read on Yom Tov Sheni.
Gra (DH v'Lachen): This is like setting a bed [on Shabbos for a weekday, which is forbidden - Shabbos 113a].
Mishnah Berurah (6): One may bring a tabletop from the Sukah to the house, just he may not set it up. If it is needed for the day, or in order that the house not look like a ruin, he may even set it up.