A hydrometer floats vertically in the test liquid because of Archimedes principle: the weight of liquid displaced equals the weight of the hydrometer.
If the liquid is denser than water, less of the hydrometer needs to be submerged to displace an equal weight, so it floats higher.
The calibrated scale on the stem is marked so the reading at the liquid line shows the specific gravity directly, with 1.000 usually marked at the level it reaches in pure water.
This is why hydrometers are used in dairies to check milk quality and in car batteries to check acid concentration.