Earth's magnetic field protects life on Earth by deflecting harmful cosmic rays and particles. It is generated by Earth's iron core and prone to periodic reversals. Cosmic rays are high-energy particles from the sun and beyond our solar system that can damage tissues when they interact with Earth's atmosphere to produce gamma rays. The aurora borealis lights are caused when cosmic ray particles are ionized in the atmosphere and recombine with electrons, emitting light. Earth's magnetic field behaves like a bar magnet with lines of force and polarity generated by convection currents in the planet's liquid outer core.