According to the website Moment of Science, maintained by Indiana Public Media, microwaves use a combination of electric and magnetic fields. These fields cause small particles, called electrons, to build up in the pointed tips of aluminum-foil coverings. This movement of electrons creates an electric field in the air surrounding the foil. If the field gets powerful enough, free electrons in the air bump other electrons out of their normal positions in air molecules, causing the sparks that people generally associate with putting metal in microwave ovens.
While food absorbs the energy waves emitted by microwaves, foil does not, which can cause the reaction described above. Although putting too much foil in your microwave can cause damage, the Food Safety and Inspection Service says that small amounts are OK, since the buildup of electric energy isn't enough to cause appliance damage or dangerous sparking. As long as you use new, smooth foil in the microwave, electrons can't build on bumpy peaks and crevices and cause a hazardous light show around your leftovers.
Always read the manufacturer's user manual for your microwave oven before using aluminum foil, since the amount that's safe to use can differ from model to model. Only use new foil that's relatively free from bumps and peaks and wrap your food to keep the foil as smooth as possible. While you can use foil to partially shield food from overcooking -- the Food Safety and Inspection Service suggests wrapping drumsticks and wings, for example -- don't completely cover your food so none of it is exposed. Because microwave energy doesn't pass through aluminum foil, completely covering your food causes it not to cook. Since microwaves are left with no place to go, totally insulating your food can also damage your appliance. If you have a microwave with metal shelves or a turntable, do not let foil touch these parts. Keep aluminum foil at least 1 inch away from the walls of your oven and turn the microwave off immediately if you see sparks.
According to the European Aluminum Foil association, foil trays used for holding food can also go in microwaves. The Food Safety and Inspection Service offers the same advice but adds that you should check the instructions on food packaging to ensure that you cook it safely. Do not put metal pans or twist ties in your microwave oven and avoid using foil containers of any kind if your oven has metal shelves or a metal turntable.