Most dogs love to play with water. Mud has a lot of water in it so it's quite wet, thus they like mud too.
Some dogs might do it out of boredom and frustration, by playing in mud it might keep them entertained. Think about little kids. Many little kids also like to play in mud, or sand. Dogs are just like really young children.
There is another theory, dogs use mud to help them to cool down. Since mud can stay on them longer than just water, it not only continuously absorb heat from dog's body directly, but the mud can also block sunlight. Think about elephant, and rhinos. They roll in mud all the time, but of course they also use the mud to protect themselves from insect bites!