It is common knowledge that some insects are attracted to light. While the exact reason for their seemingly endless fluttering around the street lights is still under debate, there are some things scientists have figured about why some insects are attracted to light and why others are repelled by it. Moths are a common example of the usual suspects found fluttering around lights left turned on at night. The opposite of these moths that are attracted to light are cockroaches, which run and hide as soon as a light is turned on in their vicinity. This is explained by a natural phenomenon called phototaxis which can be positive or negative depending on the bug and their reaction to a light source.
One hypothesis relates to the insects’ suspected internal navigation. The next theory indicates that insects are attracted to light for their own protection. These hypotheses have never been proven right or wrong because there are arguments against both. — edubook.com