Here's an optical illusion that can confuse pretty much any creature with eyes. It's a simple trick caused by a quirk in the way many animals (including humans) see contrasts. And it may explain the old adage of moths being drawn to flames.
It's no secret that bright objects seem to make colors around them look even darker. Scientists have proven the near-universality of this illusion by using a spectrum called Mach Bands (pictured above). Put a set of deepening gray stripes next to each other and you get a curious effect. Although each stripe has a uniform brightness all the way across, it appears darker on the side that touches a lighter stripe. On the other side, where it is contrasted with a line that looks darker, it looks relatively bright. This illusion, experienced by almost all creatures with eyes, provides some clues about the strange behavior of insects.
While there are bugs that will go straight at a light bulb and bang themselves against the glass, moths don't tend to be one of them, despite what people think. One entymologist, Henry Hsiao, literally tied moths to little styrofoam boats, then tracked the boats' progress through a pond, seeing exactly where the moths flew in response to lights around the water. He noticed that, while moths did fly towards the light, once they got close they tended to veer away from it.
What does this have to do with Mach Bands? Hsiao believes they're drawn to the dark. Moths seek out the darkest part of the sky, and when they see a light, the Mach contrast around it, the strip of extreme darkness, looks like the darkest part of the sky. The moth will fly to that part until it gets close to the light, at which point it gets confused and flies away. However, because it has a tiny moth brain, it may still see the darkest place it can flee to as the space right next to the same, or another, light. And so the problem goes on. Until eyes evolve to see things better, moths will keep their reputation as being drawn to trouble.
It's worth noting that some researchers disagree with Hsiao. Many believe moths instinctually fly towards light because the insects use the Moon as a navigational aid, or because natural light is up in the sky, and therefore is the perfect escape route for panicked moths set upon by predators.
Top Image: Solitude
Band Image: Aliwiki
Via Straight Dope and How Stuff Works.