Why is hair gel so slimy?

For much the same reasons anything is slimy.

Slimy is the word we use for the feel of things scientists call hydrocolloids. These are made of water and molecules that are too big to dissolve, but too small to settle to the bottom of the water.

Not all hydrocolloids feel slimy. Gelatin is a hydrocolloid that is generally made with so much protein that it is almost solid. But with less protein, it feels slimy. Soak some grains of unflavored gelatin in water, and the grains feel slimy.

Pectin (the starch-like molecule we add to fruit juice to make jelly) feels slimy. White glue feels slimy, especially if you add borax to make Slime™. The slime that snails make is a hydrocolloid.

If you remove some water from a hydrocolloid, it usually gels. That is, it becomes more solid. This characteristic is useful in a hair product, since it helps the product stay in the hair and not run down the back of your neck. It is solid enough to hold in your hand without dripping, but becomes more liquid as you rub it into your hair.

How a hydrocolloid reacts to the stress of working it into your hair depends on the nature of the particles in the water. Corn starch hydrocolloids are famous for becoming thick and almost solid when you hit them suddenly, while being almost completely liquid if you move your finger through them slowly.

Hair gel is designed with smaller particles that have the opposite behavior. Hair gel thins when stressed, so it can be worked into the hair.