Humectants work by being thirstier than your hair. They attract water molecules from the surrounding air and pull them into the cortex through any gaps in the cuticle. When the balance is right, hair feels supple and plump.
The caveats matter. In extreme dry air (desert winters, airplane cabins), there’s no ambient water to pull in — the humectant pulls water out of the hair instead, and strands get drier. In extreme humidity (Miami in August), the humectant over-pulls, flooding the shaft with more water than it can hold — the cuticle lifts, and you get frizz.
Glycerin is the workhorse humectant, in both cheap shampoos and expensive leave-ins. Panthenol (provitamin B5) is gentler and also doubles as a mild repair ingredient. Hyaluronic acid is the newer entrant — molecularly large, so it sits more on the surface than deep inside the shaft.