His mind isn't capable of the same kind of reasoning that yours is. He looks at the world through different-animal eyes. He doesn't have a conscience and he doesn't know the difference between right and wrong. Through training, he can learn how to please you and what makes you upset with him but he doesn't understand the why's of things. In order to get the most out of your relationship with your dog, it's important to accept and respect the fundamental differences between dogs and people so you can work out compromises that will make those differences easier and more comfortable for both of you to live with.
Dogs love food more than almost anything else.
Any kind of food is a temptation, spoiled or not. Dogs can be trained to stay out of the garbage as long as someone's always around to reinforce their training. Left alone, though, most dogs just can't resist the temptation. It'll be much easier, though, for both of you if you respect your dog's weakness for food and compromise by putting the garbage out of your dog's reach altogether. Using covered wastebaskets or storing the trashbin in a cupboard or broom closet is a stress-free and permanent solution.