Grog was a mixture of weak beer and rum dished out to sailors in the Royal Navy.
There was a daily rum ration and to water it down they would add weak beer.
Water would go foul on long voyages and so the only way to keep themselves hydrated was by drinking grog.
To much grog led to felling groggy (unwell)
I was a sea cadet as a kid, and this was what we were taught at Greenwich Naval Academy.
I have heard other explanations but I like this one as it makes sense.