Microwave is an electromagnetic radiation. The radiation is produced from a device called a magnetron in the microwave. Current is past through the cathode of the magnetron which develops an electrical field as electrons move from the cathode to the anode. A magnet in the magnetron causes the electrical current to rotate past cylindrical resonators resulting in the production of microwaves which is dissipated into the microwave chamber where it bounces off the walls and penetrate the food.
Did you get that? In short, the magnetron uses electrical energy and a magnetic field to produce microwaves which is then blasted into the microwave chamber to cook the food.
Food is heated due to the dipole nature of water. That is, water has both positive and negative changes. As the microwaves penetrate the food, they try to align themselves with the electrical field of the microwave just like a compass in a magnetic field. Since the direction of the electrical field is changing at a high frequency, water molecules are constantly reorienting itself to achieve alignment. This results in a significant increase in friction and molecular collision causing heat. The amount of heat absorbed by the food depends on its “dielectric loss factor”; the ability of the food to dissipate heat energy. The higher the loss factor, the more energy is absorbed.