It works by making the surface of the sunglass lens unattractive to the water molecules. The hydrophobic coating also weakens the surface tension (or bond) between the water droplet and the surface of the lens. This means the water droplet is more likely to roll off the surface of the lens.
Hydrophobic coated surfaces are also anti-static. This means that dust and other dirt particles are less likely to be attracted to them, if this does happen it is likely to just fall off. It resists stains and repels grease from fingerprints, so cleaning your lenses is quicker and easier.