The riddle
What Is the Formula for Ice?
AnswerH2O cubed
Frozen water in cubes
Water has the chemical formula H2O, and ice is simply water frozen into a solid. The real formula for ice is therefore also H2O. The riddle adds "cubed" because ice is usually frozen in cube-shaped trays, and in math to cube a number is to raise it to the third power: 2 cubed is 8.
Why it still sounds right
The joke works because H2O looks like a code and cubed looks like a power, so the whole phrase sounds like a real piece of chemistry. Said with a straight face, it passes for a formula until the listener thinks of the tray in the freezer.