Before humans meddled with nature, only wild animals existed, so the human influence formed domestic animals. Dog is the first animal that has been domesticated.
Over 18,000 years ago our ancestors were nomads (people without permanent residence, wanderers). The life of the humans resembled the life of the wolves. In those days they were rivals. They hunted in the same area and fought for the same prey. Wolves had advantages over humans thanks to their senses, strength, endurance, speed, skill... but humans invented weapons so the spear helped them kill from the afar. Then, humans came up with idea to find the way to tame the strength of this predator and use it for their own benefit.
Dog domestication started at the end of Paleolithic age (early stone age), around 12,000 years ago.
10,000 years ago, selection of dogs and favouritism of certain genetic attributes begin. The first criteria, with no doubt, was ability of a dog to communicate with humans. Humans, in fact, manipulated the animals.
Archeological finds show that around 5,000 years ago, dogs had an important role in human life. They were primarily used when hunting, because during the period of over 11,000 years when global warming shaped the landscapes, the climate change to moderate one, encouraged humans to settle. Before they domesticated animals, our ancestors domesticated plants before all else. That was the beginning of agriculture. First permanent homes were built by farmers, homes made from wood, which were taller and more firm than the ones that were made by hunters. They began living in small communities in small permanent villages. Soon the idea of locking in the animals and make meat stocks occurred. Therefor, some dogs were selected and bred for the role of the guard of the camp and alarming if any danger occurs.