Microwaves are produced by vacuum tube devices that operate on the ballistic motion of electrons controlled by magnetic or electric fields.
The frequency of the microwave is selected to match the resonant frequency of water molecules so that the energy from these waves is transferred efficiently to the water molecules as kinetic energy that is spread across the food without wasting any energy.