At the right, that's a Western Sandpiper, Calidris mauri, shown poking his long beak into his tail area. The bird is beginning a period of preening by daubing his long beak onto his preen gland, or uropygial gland. The preen gland is a fleshy, small, oil producing, nipplelike nubbin typically at the base of a bird's back, about where shorter, fluffier back feathers yield to longer, stiffer tail feathers. During preening, birds smear oil from the gland onto their beaks or heads, then rub their beaks or heads over their bodies' feathers, oiling them up. The oil keeps the feathers and their microscopic barbules supple so they don't crack and crumble. The vast majority of birds have preen glands; emus, kiwis, ostriches, and bustards don't.
Preening helps keeps the feathers in order. That's important because otherwise the feathers get brittle and break, the plumage loses its ability to insulate the body from extreme temperatures, and to repel water. Improperly positioned and interconnected feathers reduce flying efficiency. The picture at the left shows a microscopic view of barbs and barbules on a feather. You can see how the barbs, barbules and hooks fit together on our Close Look at a Turkey Feather page.
Here's what happens when a bird preens:
For a long time that last point wasn't for certain, but now there's plenty of proof that preen oil is in fact antibacterial. A 2020 paper by Diana Carneiro and others provides an overview of the subject, and documents how the oil might function.
Preening often is done socially, especially in early morning as the Sun's first rays begin warming and drying the landscape. Birds like to perch together, especially during the winter when no territorial issues arise because of nesting. One advantage of social preening is that as a bird is distracted poking among fluffed-out feathers, one or more companions surely will be looking around for dangers, exactly as the pair of Ruddy Ground-doves, Columbina talpacoti, at the right show.
Preening often goes better if you have a friend to help, as seen below with two juvenile Plain Chachalacas, Ortalis vertula, in Mexico.
Especially for shorebirds and ocean birds, oil pollution is an enormous danger, for the oil quickly removes preen oil from a bird's feathers. Wikipedia provides a good review of the situation in the Potential Problems section of its Preening Page
.