Dog Loyalty

I wonder whether dogs live with humans because we domesticated them over millenia, or just because we have free food.