It’s probably nothing more than an accident. All tetrapods (the group of vertebrates that includes the mammals, birds, reptiles and amphibians) are descended from a pentadactyl ancestor. Pentadactyl means ‘five-fingered’ and this basic pattern has been preserved in all descendant animal groups. The common ancestor of the tetrapods was a lobe-finned fish living in the Devonian period, around 365 million years ago. The fossil record also shows fish with six and seven ‘fingers’ in their fins at around the same time, but there is no clear reason why the five-fingered form survived to become the template for land life. Possibly having fewer finger bones allowed each to become stronger and this helped when crawling out of the water. However, there is nothing magic about the number five and subsequent evolutionary pressures have driven many species to fuse fingers and toes together to form thicker, stronger hooves and claws that are better suited to their particular environment.