The first instances of humans using dogs either for entertainment or other specific functions occurred around 12,000 years ago, although interaction with them is thought to go back 100,000 years. From those communities of dogs settled around humans came the first dogs breeds, when people finally reached a level of development when they could divert time and resources to cultivate specific traits in them.
Most likely, the first traits to be cultivated would have been barking at strangers, helping with hunting, guarding livestock from thieves and predators and other useful abilities for the people of those times. Not only then, but even today, in most parts of the world, especially the poorer regions, dogs still perform these tasks.
The modern dogs breeds have a relatively short history, dating back to 1873 in England, when documenting pedigrees in a register first occurred. Little is known of the different breeds until then, except that there were some landrace dogs and that people made a distinction between dog types.
After the English Kennel Club began this practice, other clubs around the globe started to do the same. This way, purebloods can be easily traced. Most breeds today have the original landrace name perhaps as homage to the long history of that breed. Others have been made more uniform in their looks by means of selective breeding and have developed into a variety of separate breeds - a good example are the retrievers.
Even if there are very many dogs breeds at the moment, more and more are still being created -some for practical purposes, others just to impress or for marketing purposes.
After a series of genetic testing on 85 breeds, scientists have managed to put them into 4 main categories, the first one being the oldest and including African and Asian dogs. The second is the Mastiff type, while the third one includes herding dogs, used to keep livestock safe. The last one is consists of modern and hunting dogs, most of them appearing in Europe in the 19 century. This is what genetics say, not what the “official” breed registries say - which most of the time are inconsistent from one country to another.
No matter the breed, a dog can be a wonderful friend for a man. Take a guide dog as an example. Labradors, Golden Retrievers and German Shepherds are the most likely candidates for the role and they truly help improve a blind person's life considerably. That doesn't mean other dogs breeds are not eligible, it just means that for every dog there is something it can do best and something it can't you wouldn't want a grey wolf as a pet for your kids, would you?