Why do microwave ovens need to have a resonant cavity? Why is it considered necessary for the microwave oven to be a resonant cavity? If it wasn't resonant then the energy  wouldn't have anywhere to go but in the food as well. So I don't understand the point of having a resonator.
PS: a similar question was asked here but I'm not asking why a resonator resonates, but rather why it's necessary for cooking the food to have a resonator.
 A: The resonant cavity presents a minimum impedance mismatch between the magnetron and the cavity. This allows maximum transfer of power from the magnetron into the cavity and hence bathes the food inside with the maximum possible amount of microwave power.
In the impedance-matched case, the load (food sitting in the cavity) is purely resistive and is due to the water molecules in the food, with no reactive load component (which causes the radiation to reflect off the magnetron's output antenna and return to the magnetron instead of flowing into the cavity).
A: #edit - as pointed out, thanks Manu,   efficiency as well as AC load (output impedance of the magnetron) concerns require the oven body to be a multi-mode resonant cavity.   I should have remembered this in the first place, as there's the famous "trick" of measuring the speed of light by par-cooking stuff in a microwave. Don't use a turntable; then the cooked spots will be an indicator of the fundamental wavelength.
The food chamber is [edited] also a fully sealed, so far as microwaves are concerned, box to prevent external escape of the microwave energy. The walls are metal so that the microwaves are reflected rather than absorbed, thus maximizing the efficiency of energy transfer into the food (which does absorb).
The magnetron itself is a resonant oscillator somewhat analogous to a laser cavity.
A: If there was no cavity then the microwaves would spill out of the microwave oven resulting in a major energy inefficiency over the with-cavity case. (Note that food could still cook this way, basically just blasting it with microwave from a microwave horn, it would just be less spatially even and much of the energy would likely be wasted.)
Given that we want the food to be in a microwave cavity, it is best that that cavity is impedance matched with the source so that the microwave energy is dissipated in the cavity with the food and not in the source electronics.
A: If one puts some food in front of a radiating microwave antenna the food very likely absorbs a part of the wave energy but what reflects off or passes through will be lost forever in free space. Metal walls around the food reflect the waves back and they get a new chance to warm the food.
The walls of the chamber in a microwave owen including the door and its window are metallic and joined together without radiating gaps - at least no radiation at 2,45 GHz is wanted to the kitchen. The design of the door is far from trivial.
There's one hole left: The input. If a wave coming from the input fits well to the dimensions and wall directions of the resonator a substantial standing wave builds up into the chamber. It hopefully has a maximum inside the food.
A part of the wave  bouncing forth and back between the walls is caught by the same antenna which feeds the chamber and goes back to the magnetron. The owen chamber should be seen as an extension of the resonators inside the magnetron. The extension hopefully has became lossy due the inserted food, not due radiating gaps nor lossy materials. The losses dissipate the microwave energy in the food.
If the chamber hadn't a resonant frequency near enough the signal frequency the standing wave buildup wouldn't happen. Leak from the magnetron to the chamber would still happen but the field strength maximum in the chamber would be substantially lower than with the resonance.
You may think: "What!!! If I output a kilowatt microwave from the magnetron to the metal chamber it unavoidably dissipates in the food because it's the only dissipating material - there's no need to have a resonator!" BUT: You do not output what you want, you output what the load takes. The rest finds its way back to the magnetron and prevents generating more. The way to maximize what the load takes is to design the chamber to have field intensity maximum in the food and that's a resonator.
A: In microwave heating, the power absorbed, is proportional to the square of the electric field. In a resonnant cavity, the electric field adds up and therefore the heating is increased but even faster than the electric field itself. As a result, more energy is absorbed by the food and less is reflected to the magnetron under resonnance

source :MICROWAVE POWER ABSORPTION IN SINGLE- AND
MULTIPLE-ITEM FOODS
H. ZHANG and A. K. DATTA (2003)
A: Non resonant loads always have a reactance component which causes reflected power back to the source. Consider a magnetron with an infinitely long waveguide terminated in a load. Just as in any RF transmission line, if the waveguide is not terminated in both the characteristic impedance Zo of the waveguide AND the output impedance of the source, a part of the transmitted energy will be reflected back to the source. Too much reflected energy can damage the source. Consider a waveguide with any odd integer multiple of 1/4 wavelength, looking into an open circuit. The result is a dead short at the source, usually accompanied by smoke and fire. The magnetron must operate into a finite VSWR of no more than 3:1 if it is to survive its design lifetime. Therefore the cavity must not present a large mismatch, and must be very close to multi mode resonance at 2.4 GHz. The characterization of standing waves in the cavity being more efficient at cooking the food is quite incidental. The standing waves must be there to prevent magnetron burnout.
