Dogs are a kind of wolf. They were the first animals that people fed on purpose, earlier than sheep or cows or chickens. People have been taking care of dogs in Central Asia since about 13,000 BC, in the Stone Age, before the beginning of farming (and possibly much earlier; maybe as long as 100,000 years ago, before people left Africa). Most likely, dogs themselves began this relationship by hanging around people's campsites (there weren't any villages yet), trying to snatch some of their garbage to eat. At first, people must have tried to scare the dogs away. But after a while, some of them realized that the dogs ate rats, and also helped to clean up food garbage that drew flies and other insects. So campsites with dogs were cleaner and healthier than campsites without dogs. Fewer people got dysentery and died.
The people who lived in these cleaner campsites grew up stronger than people who shooed away dogs, and there were more of them. Eventually, the dog-lovers pretty much took over, all over the world. And dogs evolved to be able to digest more and more people-garbage, especially grains.
Somewhere around this time, people probably began to see that the dogs could do other things too. Dogs would bark and let you know if any big animals or human enemies were coming. Dogs could let you know if the baby was getting into trouble. So people began to encourage the dogs to hang around. At some point, people also began to teach dogs to obey them, and they also started to use the dogs to help them hunt other animals, and to pull sleds. Dogs were the earliest domestication of any animal, and may have given people the idea of domesticating sheep and goats, which came next. Nobody's sure whether this domestication of dogs happened only once, in one place, or many times, all over Europe and Asia, but all known dogs today, all over the world, are descended from those Central Asian dogs of about 13,000 BC. Even Native American dogs came to the Americas from Asia. Today's European dogs probably came to Europe with the Indo-Europeans from Central Asia, replacing earlier European dogs, just as Central Asian cats replaced earlier cats in China.
Today you probably think of your dog as a pet, and give it food. But in antiquity and in the Middle Ages, hardly anyone was rich enough to give food to a dog on purpose. Most dogs had to find their own food in people's garbage, or they had to eat rats. Only working dogs that herded sheep or pulled sleds would have been given food. So most dogs, like most people, were skinny and had lots of diseases and bugs. Even today, around the world, about three out of four dogs are not pets, but live on their own in human villages and towns and find their own food.