Moisture and temperature are the two critical factors in optimal food storage.
Moisture - the humidity in the storage environment should be low. If dried foods pick up moisture from the storage area, molds and bacteria can grow. This can lead to spoilage and illness. Moisture can also lead to the breakdown of some packaging materials (paper degradation and metal rusting). In areas of high environmental humidity a dehumidifier may be needed.
Temperature - The optimal temperature range is in the cool to moderate range, approximately 40 - 70 degrees F. Research at Brigham Young University (Ref. 1.) on long term storage has shown that wheat retained an acceptable quality for 25 years stored cold (basement) and only 5 years stored hot (garage or attic). Grain germination rates will decline and vitamin breakdown rates in all stored foods will increase as the temperature increases. Canned foods should not be allowed to freeze. Freezing will bulge cans and may cause seem failures leading to a potential for foodborne illness. Dry foods can freeze without concern.
Other factors - Direct sunlight is detrimetnal to foods. It can speed deterioration of both the food and the packaging. The heat from sunlight can also speed deterioration. Always store foods off the floor. Flooring materials, especially raw concrete can leech chemicals into stored foods. These chemicals can pass through plastics and can cause rust to form on metal.
Reference 1. Green R., D.J.Rose, L.V.Ogden, O.A.Pike. "Effects of long-term storage on quality of retail-packaged wheat." J. Food Sci. July 2005: Abstract # 54H-8.