Styrofoam keeps things cold because it is made from polystyrene, a substance known for its low thermal conductivity, which is its ability to transfer heat. Styrofoam also uses millions of microscopic air bubbles as insulation to slow the progress of heat.
Styrofoam has the ability to keep things cold for long periods, but it does not have the ability to make a warm item cold by itself. Heat still has the ability to pass slowly through the insulated walls of Styrofoam. For this reason, ice and cold packs must be used in conjunction with Styrofoam containers to keep items chilled over time.