It seems that people and dogs have co-evolved through history to live together for mutual gain. They hunt together, and both human and dog eat based on their mutual successes. Humans and dogs form a unique inter-species social circle with all of the complex emotional bonds this entails. No wonder we love our doggies and they love us to the bone: it is written in both our DNA!
Dogs have evolved a highly keen sense of smell and rather poor eyesight, while people have lost their sense of smell (largely) and developed keen eyesight; a perfect pairing! Dogs provided an early warning security service for human villages using their super-duper hearing, and still do.
Luckily the social systems for humans and dogs are very similar, and dogs have a late social development period, with dogs being most imprintable prior to 4 months of age. We mesh together very nicely and our bond has stood the test of time.