The standard answer is that moths aren't attracted to bright lights, they're confused by them. Many species of moths migrate and they use the Moon as a navigational cue. Then, humans come along with artificial lights, which appear brighter than the Moon and those become the moths' point of reference, instead. By this theory, the moths don't even mean to end up at the light. They're just trying to maintain a constant angle of flight relative to it. But, because they keep getting closer, that angle keeps changing until, BAM!, they run into their artificial moon.
Trouble is, there are a lot of holes in that theory. Not all the moths that are attracted to lights are migratory, for one thing. For another, there are studies showing moths beelining for the light, rather than spiraling towards it, as you'd expect if the effect could be explained by navigational error. So why head towards the light? Other theories include: An attempt to get a better look at the surrounding area for places to hide from predators; a case of mistaken identity where male moths confuse the spectrum of light for that produced by female moth pheromones; and a different case of mistaken identity where the moths confuse artificial light for night-blooming flowers. All those theories have holes, though. So the ultimate answer seems to be that we still don't know why moths head towards the light. Maybe you can do the research and figure it out.
Image: basking in the light, a Creative Commons Attribution (2.0) image from ganesh_inxs's photostream