Flies like beer because it contains glycerol. They will drink it until they are intoxicated.
According to the University of California, Riverside, flies sense glycerol, a sweet-tasting compound that yeasts make during fermentation. There's yeast in beer, and beer undergoes fermentation.
The flies sense the glycerol because they have a receptor known as Gr64e.
Once a fly has settled on beer, Gr64e detects glycerol and transmits this information to the fly's neurons, which then influences the fly's behavioral response.
Last year last year UCSF researcher Ulrike Heberlein determined that fruit flies will drink beer until they can drink no more.
The flies choose to consume alcohol to intoxicating levels.
They will do so even if alcohol is made unpalatable, and they relapse to drinking high levels of alcohol after being deprived of it.