hearing organs of moths have evolved several times independently in the various groups. Tympanic ears of moths evolved from specialized mechanoreceptors (chordotonal organs) that in their original form react to stretching. The pilifer organ of hawkmoths have a different origin, because they are not tympanate but derive from mouthparts. Most moth ears are used only to detect echolocation calls of bats and must have evolved in this context. In some species ears are also used for intraspecific communication (e.g. courtship) but this is likely the result of secondary evolution.
Attached please find an excellent review on this subject.
Yes, it is the same type of evidence that bacteria, eukaryotes, and other organisms developed light-sensitive organs such as eyespots and eyes in response to light stimulation. Organisms that can sense their environment or gradients in the environment and then move toward or away from good or bad things tend to survive and reproduce better than those that don't. So evolution will drive organisms to have systems such as ears and eyes, temperature sensors, food sensors, etc.
It just occurred to me, that you are probably asking about antennae which today have chemoreceptors to respond to pheromones and other chemicals in the air, more than to sound waves. I would guess that the answer would lie in the analogous structures in related insects such as butterflies and do they mostly respond to sound or to scents.
I presume that the question is about the tympanum that is found in several groups of moths. How about invoking moth echo-location signals as the selective force? There is a large literature on the subject.
hearing organs of moths have evolved several times independently in the various groups. Tympanic ears of moths evolved from specialized mechanoreceptors (chordotonal organs) that in their original form react to stretching. The pilifer organ of hawkmoths have a different origin, because they are not tympanate but derive from mouthparts. Most moth ears are used only to detect echolocation calls of bats and must have evolved in this context. In some species ears are also used for intraspecific communication (e.g. courtship) but this is likely the result of secondary evolution.
Attached please find an excellent review on this subject.
As Danilo says, tympanal organs arose multiple times, and in fact are located on different body parts in different moth groups. In Noctuoidea, they are on the thorax, while in Geometridae and Pyralidae, they are located on the abdomen, laterally or ventrally, respectively. The fact that hearing has evolved multiple times in different lineages is a pretty good indication that it is an adaptation - most likely to bat sonar.
A spin-off question: what happens to moths that do not have ears, and therefore can't detect bats? The Hepialidae as far as any one knows have no means of detecting sound (= they are deaf!). A substantial proportion of the species are crepuscular flyers, active only for a short period, as little as around 30 minutes in some species, around sunset; in some of these there is a further short flight around dawn. It has been suggested that they are exploiting a time window in which birds have ceased predation activity (in summer this is quite a long time before sunset) and bats have not yet become fully active. There are however some species which fly in the night, or in full daylight, and nobody seems to have had any suggestions about their predator avoidance strategies, except that (apart from the leking species) the moths do fly extremely rapidly, and are therefore almost impossible to intercept in flight!
Key references (search for further citations etc) are