Out of the 16,000+ varieties of flying insects, in North America, most of them are what we call Phototactic. This phenomenon is called Positive Phototaxis (scientific speak for "drawn to light sources"). The inverse is Negative Phototaxis, demonstrated when certain bugs run away from the light. It is not yet discovered exactly why and how this works, but Scientists believe that it's because flying insects use light, such as the sun and the moon, for navigation.