Not only may one cook on Yom Tov, but many other melachos that relate to food preparation are permitted on Yom Tov. By and large, those melachos which are permitted on Yom Tov (because they have some sort of food use) are even permitted for non-food use. The most well-known example of this is that one may carry a siddur or coat or other things outdoors even if there is no eruv. This is because since/metoch “carrying” is permitted for food use, such as to bring food to a neighbor, so too carrying is permitted for non-food use. There are many limitations and details to the halachos of which melachos are permitted on Yom Tov and under which circumstances they are permitted, and such questions should be addressed to a Rav.
A practical leniency relevant to Yom Tov relates to the melacha of borer. On Shabbos, one may only separate items which are mixed together if three conditions are met: (1) the desirable (“good”) item is pulled out of the less-desirable one (“bad”), (2) the separation is done use a hand or simple tool, such as a fork, rather than with a strainer or other specialized tool, and (3) the separation occurs reasonably close to the time when the food (or other item) will be used. On Yom Tov, borer is also forbidden, but the first condition is leniently modified to read “the person should separate in the easiest manner possible”.
One may not create a “new” fire on Yom Tov, even if that fire will be used for cooking, and one may also not extinguish an existing fire. Accordingly, on a stovetop, (a) one may raise or lower the size of an existing flame, if that is done to help with the food preparation, (b) one may not turn off an existing flame, and (c) one may generally not turn on a new flame unless there is a working pilot light (in which case, the “new” flame is an extension of the existing pilot). In an oven or warmer, (d) if the size of the flame is adjusted using a touch pad or a knob which changes a digital display, the oven’s temperature cannot be adjusted, (e) if the oven uses a simple knob with no digital display, then when the flame is actually burning in the oven the knob may be turned to a higher setting, and when the flame is out the knob may be turned to a lower setting.
In general, one may not do any preparations on one day of Yom Tov for the next day – whether that “next” day is Yom Tov, Chol HaMoed, or a regular weekday, and regardless of whether the preparation involves melacha or not. This means that preparations for a meal served on the second night of Yom Tov cannot be made until the second day has actually begun, which is somewhat inconvenient in a hotel or similar setting. Two ways in which this issue is somewhat ameliorated are (a) based on a ruling from Rav Schwartz, the cRc uses a relatively early “shiur” to determine that the first day of Yom Tov has ended, and the second has begun, and (b) a pan of food may be put into the oven even if the pan includes more food than is needed for just that day (marbeh b’shiurim) (but a second pan cannot be put in just for the next day).
A number of people asked for details of the cRc's "early shiur" for beginning melacha on the second night of Yom Tov. That shiur is the one given by Bnei Tzion 2:16 who rules that bein hashmashos ends when the sun is 6 degrees below the horizon, and once that time passes, we allow non-Jews to make preparations for the evening seudah.
Just like one cannot prepare on Yom Tov for a second day of Yom Tov or for chol HaMoed, one may also not prepare on Yom Tov for Shabbos. However, in this last case, if one sets up an “Eruv Tavshilin” before Yom Tov, they are permitted to cook and do other preparations on Friday (Yom Tov) for Shabbos. The halachos of Eruv Tavshilin include a number of important details, which we look forward to discussing before a future Yom Tov where it is relevant.