It dates back to the days when homes would eke out roasts and vegatables to last as long as possible. When the left-overs were no longer required, they 'went to the dogs' and were fed to domestic or working dogs. It's become an expression for something that has had every last ounce of usefulness rung out of it, and is now on the last leg of its disposal.