Straight from wikipedia:
Auroras are associated with the solar wind, a flow of ions continuously flowing outward from the Sun. The Earth's magnetic field traps these particles, many of which travel toward the poles where they are accelerated toward Earth. Collisions between these ions and atmospheric atoms and molecules cause energy releases in the form of auroras appearing in large circles around the poles. Auroras are more frequent and brighter during the intense phase of the solar cycle when coronal mass ejections increase the intensity of the solar wind.
Auroras result from emissions of photons in the Earth's upper atmosphere, above 80 km (50 mi), from ionized nitrogen molecules regaining an electron, and oxygen atoms and nitrogen molecules returning from an excited state to ground state. They are ionized or excited by the collision of solar wind and magnetospheric particles being funneled down and accelerated along the Earth's magnetic field lines; excitation energy is lost by the emission of a photon, or by collision with another atom or molecule:
oxygen emissions: green or brownish-red, depending on the amount of energy absorbed.
nitrogen emissions: blue or red; blue if the atom regains an electron after it has been ionized, red if returning to ground state from an excited state.
Oxygen is unusual in terms of its return to ground state: it can take three quarters of a second to emit green light and up to two minutes to emit red. Collisions with other atoms or molecules absorb the excitation energy and prevent emission. Because the very top of the atmosphere has a higher percentage of oxygen and is sparsely distributed such collisions are rare enough to allow time for oxygen to emit red. Collisions become more frequent progressing down into the atmosphere, so that red emissions do not have time to happen, and eventually even green light emissions are prevented.
This is why there is a color differential with altitude; at high altitude oxygen red dominates, then oxygen green and nitrogen blue/red, then finally nitrogen blue/red when collisions prevent oxygen from emitting anything. Green is the most common of all auroras. Behind it is pink, a mixture of light green and red, followed by pure red, yellow (a mixture of red and green), and finally, pure blue.