The number of toes an animal has depends on the conditions in which it evolved.
Differing numbers of toes is most obvious in hoofed mammals like horses, deer and giraffes. Animals with hooves are split into two categories, even-toed and odd-toed.
Horses, donkeys and zebras only have one toe in the form of a single hoof. They evolved living in dry, open grasslands and needed to be able to run fast to escape predators.
Camels, giraffes and deer all have hooves split into two toes. This helps the animal move over different surfaces like sand or mud. Having two toes also helps an animal manoeuvre itself, like a deer quickly changing direction while running.
Rhinos and tapirs have three toes. This helps with travelling through thick swamp, but also helps spread out the animal’s weight. These hooves are filled with pads of fat to cushion the blow when the animal runs.
Pigs and peccaries have four toes and are excellent at travelling across all types of terrain like a 4X4 vehicle. Wild boars are excellent runners and survive in a wide variety of habitats because they are so adaptable.
Image from www.flickr.com/photos/stuutje