The lenses in compound eyes of butterflies and moths contain an array of nipple-shaped protuberances, or corneal nipples. Previous work has suggested that these nipples increase light transmittance and reduce the eye glare of moths that are inactive during the day. This work builds on but goes further than earlier analyses suggesting a functional role for these structures including, for the first time, an explanation of why moths are attracted to UV light. Using a phylogenetic approach and 3D optical modelling, we show empirically that these arrays have been independently lost from different groups of moths and butterflies and vary within families. We find differences in the shape of nipples between nocturnal and diurnal species, and that anti-glow reflectance levels are different at different wave-lengths, a result thereby contradicting the currently accepted theory of eye glow for predator avoidance. We find that there is reduced reflectance, and hence greater photon absorption, at UV light, which is probably a reason why moths are attracted to UV. We note that the effective refractive index at the end of the nipples is very close to the refractive index of water, allowing almost all the species with nipples to see without distortion when the eye is partially or completely wet and providing the potential to keep eyes dry. These observations provide a functional explanation for these arrays. Of special interest is the finding that their repeated and independent loss across lepidopteran phylogeny is inconsistent with the explanation that they are being lost in the ‘higher’, more active butterflies.