In prehistoric China, for hygiene and safety reasons dogs weren’t allowed inside the city walls.
It was also forbidden to dispose of garbage within the city, and so the designated dump outside the walls was where the stray dogs found food.
When undesirables and criminals were banished from the city and forced to compete with the dogs for food at the garbage dump, it was said they had “gone to the dogs.”
Today we often say that someone who has wasted his life has “gone to the dogs”.