JEL's answer is surely correct as to the meaning and very early instances of glue as a slang word for beer. As for why anyone might have made a connection between glue and beer in the first place, I suspect that it has to do with a fancied similarity between the containers used by workingmen (especially before and, in some places, during Prohibition) to carry the two substances: pails. Thus, J.E. Lighter, Random House Historical Dictionary of American Slang (1994) has this subentry for the noun glue:
glue n. ... 2. beer [Example:] 1945 Yank (Nov. 9) 15: I gotta ... get myself a few pails of glue before the bars all shut down.
Lighter's quotation from Yank: The Army Weekly, volume 4 (1945) appears in a mock interview consisting of reporters, an Army Air Force pilot (the "hero"), and an Army PR flak. It runs at greater length as follows [combined snippets]:
REPORTER: Lieutenant, how do you feel about being back in the States?
HERO: I'm plenty PO'd with the attitude here, and I—
PUBLIC RELATIONS: Let me explain that phrase, gentlemen. The lieutenant pays high tribute to the fighting skill of his comrades in arms in the air. ...
REPORTER: Is it true, lieutenant, that you're going to teach gunnery for a while before being discharged?
HERO: Yeah, somebody has to give the kids the ungarbled word. The stuff they taught me in training almost caused me to get the backs of my knees shot off several times—
PUBLIC RELATIONS: Er, gentlemen, let me simplify that. The lieutenant has high words of praise for the training program given our fledgling flyers, and—
HERO: Say, fellows, I'm sorry as hell, but I gotta get out of here and get myself a few pails of glue before the bars all shut down. See you!
Intriguingly, Lighter identifies another slang meaning of glue that is even older than the "beer":
glue n. 1. money. [Examples:] 1896 in Rose Storyville 127: Kate Soaked the Sloan Diamonds to Raise the Needful—Florie Davis Will Help the Partners to Raise More Glue. 1941 Kendall Army & Navy Sl[ang] 6: Glue...money.
But I see no connection between these two senses of glue—nor is it clear why money should be called glue, other than the rather cynical notion that money is what holds communities, families, etc., together. Still, it is noteworthy that the older glue = money was in use in the U.S. military at the same time that the somewhat younger glue = beer (or other alcoholic beverage] was.