So, why do fruit flies like alcohol?
The answer is not so much linked to the answer to a joke or a riddle. New research has shown that fruit flies - Drosophila melanogaster - seek out alcohol to kill off parasitic wasps (Leptopilina) living in their blood. Alcohol exposure also discourages the wasps from laying their eggs in the fly larvae in the first place.
Drosophila are unique insects because they often subsist on the yeast growing in rotting fruits. The yeast convert the fruit’s sugar into energy through the process of fermentation, which produces ethanol as a byproduct. They are also attracted to alcohol, as many beer drinkers discover! So fruit flies regularly spend their lives swimming in—and consuming—the alcohol, which is toxic for most organisms.
The article reference is:
N.F. Milan et al., “Alcohol consumption as self-medication against blood-borne parasites in the fruit fly,” Current Biology, doi:10.1016/j.cub.2012.01.04, 2012.