Over 40 million years ago, an early ancestor of the modern dog was a tree climbing cat-like animal called a Miacis. These animals had five toes to successfully scale and live in the treetops. Eventually, the Miacis evolved to live on the ground and became specialized hunters -- more like our dogs today.
As hunters of fast moving prey, speed became an important factor. This added speed required a change! Evolution rocked dog's legs forward so that their heel would no longer touch the ground. As a result, they began to walk on their toes, with the fifth toe now unable to touch the ground.
Voila, the dewclaw! Today, most dogs have dewclaws only on their front paws, and it is rare to find them on their back paws. However in several breeds, such as the Great Pyrenees and Briards, rear dewclaws are common, they may even have a double dewclaw!
It is not uncommon for dogs with injury-prone dewclaws to have them removed. Some puppies have them removed before they are weaned. Be sure to ask your vet if you are concerned that your dog's dewclaws are at risk for injury. They will know best how to keep your furry friend's paws safe and healthy!
Source: Psychology Today