The earth's core is made up of hot, molten iron and nickel under pressure. The effect of the iron creates magnetic fields that shoot out from the center of earth, through earth's layers and around the planet. This forms the earth's magnetosphere.
The protons and electrons creating the aurora come from the sun's corona. Due to its intense heat the sun's hydrogen and helium atoms vibrate and lose electrons and protons. These particles have a high energy charge that they can escape the gravitational field of the sun and make their way towards earth at about a million miles per hour. This is also known as the solar wind. They form a group of plasma, which is an electrically charged gas, and travel away from the sun.
The magnetosphere is very important, since earth is constantly being hit by charged energy particles from the sun. When these particles encounter earth they mostly bounce off the magnetic field. But, some of these particles manage to get through to the places where the field is weakest at the north and south poles
After traveling 93 million miles across the galaxy, the particles start to react. When the electrons and protons encounter oxygen and nitrogen atoms they transfer energy and excite them. This causes them to emit photons, which are small bursts of energy in the form of light.
Depending on where in the atmosphere they interact different colours will form. Oxygen atoms emit red and green colours, while nitrogen is responsible for beautiful blues. All together they can form hues of pink, purple, and white. The polar lights are best seen at night in areas near the north or south poles, and are ideal since Aurora is dimmer at day and is easily out shined by the sun.
And there you have it. The gleaming beauty of the night sky.