Pigs wallow in mud because it feels good to them.  Pigs have no sweat glands in their thick skin to serve as a cooling system. Wallowing in mud helps pigs to keep cool on a hot day.  The coating of mud also adds a protective layer against the sun and helps keep off biting insects.

Pigs have a reputation of being dirty and stupid because they wallow in mud. But they keep themselves cleaner than most other farm animals.  Pigs have been shown to be the most intelligent of all hoofed animals.  They can be taught to perform tricks and can even become pets.–Dick Rogers