Why does metal spark in a microwave?

The heart of the microwave is the magnetron which is nothing more than just two magnets that radiate energy or electrons at very high frequencies which is then transmitted like an antenna through a waveguide who's job is to concentrate and direct the energy so it can bounce off the walls of the cooking cavity. This high frequency excites the water molecules in your food in the form of vibrations and heat is produced as a result to cook your food.

When the flow of energy in the cooking cavity or inside the oven is disturbed by a metallic object it can cause a spark. The spark is an arc of electricity between two irregular points of metal in close proximity or to the metal wall of ther cooking cavity. The build up of energy between the two points of the metal will overcome the insulation properties of air and start conducting or arcing. This will continue as long as the energy is constantly being provided by the magnetron. Also keep in mind the size of the cooking cavity is designed for the frequency and energy output of the magnetron, placing a metal object within the cavity can cause reflections back to the magnetron, damaging it.

There are some microwaves that allow metal to be used inside so you must follow the manufacturer's manual. If your microwave shows damage in the form of pit marks along the walls or the mesh screen in the viewing window, you might want to replace it, these are areas where the microwaves can escape through.