According to HowStuffWorks, aluminum foil is a good insulator because it prevents the radiation of heat by reflecting it back at the source. Since aluminum foil reflects the emission of heat, it tends to be a better insulator than other materials that just slow down the flow of heat from one area to another.
The side that the aluminum foil is placed on affects how it insulates. For example, placing aluminum foil on the outside of a box keeps the inside cooler by reflecting heat away from the box. However, placing aluminum foil on the inside of a box helps keep heat from escaping. According to the Cold Climate Housing Research Center, foil is often used for reflective insulation in attics, but is most effective in warm climates.
Insulation is not used to keep cold air from entering an area. Instead, it is used to slow down or prevent the flow of heat from one area to another. Heat is only able to flow in a single direction: from something warm to something cool. Insulation serves as a way to slow down this process. Even insulation in a refrigerator is not used to keep cold air inside but to prevent heat from getting inside the refrigerator.