Pigs are one of many animals that wallow in the mud, using the roll in filthy water to keep cool in the absence of sweat glands. And that particular arrangement might be just how ancient pigs liked it.
Dutch researcher Marc Bracke thinks this wallowing behavior says something fundamental about pigs and their fellow wallowers, such as hippos. He thinks it's an expression of a love of the water that goes all the way back to our most ancient aquatic ancestors, and pigs happen to be one of a few species that are able to ward off an attack while they're relatively vulnerable in the water. He explains:
"We all evolved from fish, so it could be that this motivation to be in water could be something that was preserved in animals that are able to do so...Pigs, like many carnivores, are relatively large animals with enlarged canine teeth, so they would be better able to fend off an attack. [Pigs] did not evolve functional sweat glands like other ungulates because they liked wallowing so much."
Bracke points out that researchers tend to think of pig wallowing in terms of sweat glands - in other words, pigs have to wallow because they don't have sweat glands. But Bracke suspects that it's the other way round, as other animals were forced to evolve sweat glands because they lost the luxury of diving into the mud.
The fact that this is a new idea might have something to do with the fact that, since we humans have sweat glands, there's a natural tendency to think of our anatomy as a sort of "default" for others, so we tend to think pigs wallowing requires more explanation than why we sweat. It's a natural and perfectly understandable way to conceptualize evolution, at least in rough terms, but as Bracke has shown it can lead us to sometimes overlook the obvious.