why do onions spark in the microwave

Diced onion spark in the microwave because diced onions do not contain much water. The steam pressure will be ejected from the layers of onions and forming a connecting conducting plasma. In diced onions, several chunks would need to be electrically aligned in a random manner to form an antenna for arcing and burning.

These antennas will form a dielectric transmissions line and the interconnected hunks form a sort of resonant antenna to build up the large fields.
So, if you happen to have a misrowave you're getting rid of, a redneck at heart, and an onion, here something fun to do. 1.

Throw the onion in the microwave (duh) 2. turn the microwave on high for ~15 minutes 3. look in the window and enjoy the show. What you will see is sparks off the onion, possibly making the onion explode. this is because (like throwing a fork into your macronoodle) the water in the onion conducts electricity.

Microwaves are sort of the same thing as electricity, so the electricity builds up in the water and makes a mini lightning bolt once the amps and/or volts gets high enough (cool, huh).

If this happens deep enough down in the onion, the onion will explode, destroying your microwave. Then, whether or not the onion and/or microwave exploded, look at the damage. You will likely find burn scars all over the microwave, but only at pin-points on the onion. this is because the microwaves spread out over the surface of the microwave's innards, but the electricity only exits the onion where the water bubble was.