i've thought about that many times too, and my research has lead to several conclusions:
1. genetics play a large role. if a dog is healthy to begin with, it can withstand much more than a dog that is already prone to a lot of things due to bad breeding practices. due to closed stud books, breeding stock becomes limited and genetic diseases are more and more prevalent, especially in bloodlines of irresponsible breeders who don't do any health testing and don't eliminate unfit dogs from their breeding program rigorously. not too long ago people were culling sickly/unfit dogs and those people who bred strictly for working ability only bred the healthiest, best performing dogs anyway.
2. the commercial food available nowadays is not the same as what was available decades ago, and back then it was still pretty common to feed home prepared food too. horse meat was more widely used as commercial dog food early on, and it was canned or frozen instead of stabilized with chemical preservatives. with the human food industry expanding and more and more byproducts of this available cheap, many of the large food companies have bought up the originally smaller, independent pet food manufacturers and changed ingredient compositions. chemical stabilizers came on the market that made it easy to preserve dry foods and give them a longer shelf life.
further, dogs evolved as scavengers with a carnivorous background, which enables them to survive on a very varied diet. it is true that their teeth and digestive tract is designed to primarily digest and utilize meat, but that does not mean they need a "meat only" diet to do well. however, there's a huge difference between a diet of table scraps etc. and a food product that contains poor quality ingredients, chemical stabilizers, artificial colors and so on. if you want my personal opinion, i think any dog fed a reasonable composition of table scraps (e.g. not junk food, but meat, veggies, rice/potatoes etc.) is way better off than one eating kibble from the grocery store.
3. i'm convinced that proper exercise is critically important to a dog in order to stay healthy. a working dog is going to get that one way or another, a "couch potato", who just goes for a walk around the block for 10 minutes a day, doesn't. your average outside dog is also going to get more exercise, unless he's in a pen or tied up pretty much all the time, in which case i doubt he'll be particularly healthy or long lived.
4. over-vaccination is hard on the immune system. if a dog manages to build up antibodies from being exposed (and either getting a disease and surviving, or mounting a successful immune defense) you have the same effect as vaccination. strong, healthy dogs build up a natural defense, the immune system is constantly "updated". the weak dogs who can not mount a sufficient immune defense die - survival of the fittest. the survivorspass on their superior genes to the next generation, which goes back to point number one: good breeding practices.
last but not least - all that aside, you have the same effect in dogs that you have in people, the kind of "my grandma lived to be 100 years old and she smoked and drank and ate fried foods all her life". i guess that may also link back to good genes, but you'll never know what a healthier lifestyle would have brought about.