The scientific name for the twinkling of stars is stellar scintillation.The light of the star is bent(refracted)many times and in random directions from moment to moment because light passes down through many layers of air and each layer has different temperatures,pressures, densities and other factors.Each layer will bend and affect light in a certain construction from our perspective the light will appear in a location then after millisecond it will appear in other location and this seems like twinkling.
The Earth has its own magnetic field , it acts like there is huge bar magnet buried inside,but this bar magnet is not on the earth rotational axis it is shifted by some angle.The south of the bar magnet is on the magnetic north and the south polarity is on the magnetic north(image).As opposite polarities attract the magnetic needle (north) is attracted to the south polarity in the magnetic north.That’s why the needle always points north.If you want to know “why earth has magnetic field?”go to letter E.