A locomotive's motion depends on the friction between its wheels and the steel rail. When rails are wet or slick, friction can decrease to the point that the wheels slip or spin, like an auto on an icy road.
To increase friction, each locomotive carries a quantity of sand. On steam locomotives, sand is carried in a dome on top of the boiler, where the boiler's heat helps keep it dry; for diesels, one or more sand boxes are located inside the body of the locomotive. The engineer's sanding valve uses air pressur to drop dry sand onto the rails just ahead of the wheels.
Dry sand is loaded into the locomotive from a sanding tower, such as this diesel-era example from a Grand Trunk Western yard on Chicago's South Side. At one time, most large terminals had a drying house where sand was prepared for use; today, dry sand is transported to terminals in covered hopper cars, then blown to the top of the sanding tower with compressed air.