פסחים מו:
"האופה מיו"ט לחול ... רבה אמר אינו לוקה אמרינן 'הואיל'"
If one has finished his meal on יו"ט & has no intention of eating till after יו"ט is over, if he now cooks something, ר' חסדא says he gets מלקות because he is cooking on Yom Tov for חול which is not "צורך יו"ט". רבה holds since it’s possible (הואיל) that guests might arrive & this food will ultimately be needed for יו"ט, he doesn’t get מלקות. (Rashi) Rav Elchanan zt”l [קובץ שעורים פסחים קצג] explains that רבה holds we look at the מעשה. If one originally cooks on the ספק that maybe guests will arrive, it would be permitted. Just like one may cook for himself on the chance he might get hungry later. So we see that this מעשה of cooking is a מלאכת היתר, since the reality is that guests might arrive. רבה holds his מחשבה (or lack thereof) can’t turn this action from היתר to איסור. But ר' חסדא holds that one’s מחשבה can change the מעשה from a permitted action, to a מעשה איסור. He quotes the מאירי that even ר' חסדא who says one would get malkus, if guests actually do pop in, even he would agree that there is no malkus. This, Reb Elchanan says, is a problem with his פשט.
The Mishna Berura explains [תקכ"ז א'] explains that when יו"ט falls out on ערב שבת we make an עירוב תבשילין. This allows us to cook on Yom Tov for shabbos. Even according to those that hold cooking on Yom Tov for shabbos is an איסור דאורייתא, the possibility of "הואיל" takes off the דאורייתא & makes it only a איסור דרבנן & with the עירוב תבשילין in place, the רבנן were מיקל for כבוד שבת. He adds that since we are relying on "הואיל", in conjunction with the עירוב תבשילין to allow the cooking, we should make sure the food cooked on יו"ט for שבת, is cooked enough that if guests would stop in before יו"ט is over, it would be edible enough for them to eat.
Tosfos[סוף ד"ה רבה] asks once we say "הואיל", how can anyone ever be עובר any איסור מלאכה on שבת? If one does a מלאכה we should say he is פטור because maybe there will be a חולה שיש בו סכנה which would make this מלאכה permissible? Tosfos answers that we only say "הואיל" on things that are שכיח & a חולה שיש בו סכנה appearing suddenly is לא שכיח.