Many insects are quite dramatically attracted to artificial light sources. So called 'Phototaxis'.
Moths in particular are (famously) so drawn to light sources that they frequently get burnt in candle flames.
Moths are known to have a visual system that is extremely sensitive in low light conditions - presumably an advantage for nocturnal species. They are also known to migrate using moonlight and windspeed as navigational cues. But a precise, agreed, explanation as to why they circle lamps etc is currently lacking.
Moths frequently appear to circle artificial lights, although the reason for this behavior remains unknown. One hypothesis to explain this behavior is that moths use a technique of celestial navigation called transverse orientation. By maintaining a constant angular relationship to a bright celestial light, such as the moon, they can fly in a straight line. Celestial objects are so far away that, even after travelling great distances, the change in angle between the moth and the light source is negligible; further, the moon will always be in the upper part of the visual field, or on the horizon. When a moth encounters a much closer artificial light and uses it for navigation, the angle changes noticeably after only a short distance, in addition to being often below the horizon. The moth instinctively attempts to correct by turning toward the light, thereby causing airborne moths to come plummeting downward, and resulting in a spiral flight path that gets closer and closer to the light source."
Source : Wikipedia
Update, Apr. 2023
A report in bioRXiv details new research which presents a possible explanation as to why insects circle around bright lights.
The idea is based on (previous) findings that many insects tend to orientate their dorsal (top) side towards bright lights. This is thought to have the function of helping the insect to know which way up it is (top side towards the Sun/Moon).
When encountering a bright artificial light, insects (mistakenly) orient themselves with their 'back' towards the light - which disturbs their normal flight behaviour and causes then to circle.
Although this theory isn't new, the research team were able to demonstrate it in action using real-time 3D tracking tech.
See : Why flying insects gather at artificial lightbioRXiv, Apr. 2023
Although the question of why the insects circle appears to have been resolved, the question of why they appear to be strongly attracted to bright lights (from a distance) remains enigmatic.
Other mechanisms might contribute to the arrival of insects at nocturnal light sources over longer ranges."
[ Source link above ]
The research team, however, suggest that perhaps insects aren't attracted as such, but are simply 'trapped' as they pass by a light source.
[…] our results suggest artificial lights may only trap passing insects rather than attract them directly from farther away.
[ Source link above ]
If this part of the hypothesis is confirmed - in the sense that it's conclusively shown that the insects are not attracted from some distance away (as many believe they are) - the question as to why moths (and other insects) congregate around bright lights will have been resolved.
Note: A highly detailed follow-up of the study cited above study was published in Nature Communications Vol. 15, Article number: 689 (2024)