Whether you live in the city or the countryside, refuse is a fact of life. Dumping your garbage in the closest spot is generally not the best idea. Food waste and other trash attract vermin of all kind -- things as small as mice, rats and insects right on up to bears looking for a tasty rotting snack.
The dangers here are myriad. Rats and mice can drag diseases into the vicinity. Larger animals are dangerous for the same reason, but they also have the added danger of size and sharp teeth; even if they don't get you, they can cause property damage galore in a furry flash.
No matter where you live, put your waste in a trash container with a solid lid that keeps animals (and children) at bay. If you do reside in an area where larger mammals like raccoons and bears will make a mess of your trash bin, you may need to take extra steps to protect your garbage from intruders, such as locking metal bins.
In doing so, you'll reduce wildlife confrontations and keep the rest of the neighborhood safer, too.