Sand is able to keep water warm for the longest period time, when compared to air and Styrofoam.
Thermal insulators are materials that are used to reduce, minimize or prevent heat transfer from occurring. Heat transfer happens through conduction, radiation or convection. By covering the surface of a container with a layer or several layers of insulating material, heat can be prevented from either entering or leaving the container.
Generally, materials that are poor electrical conductors have been found to also be poor heat conductors. Electrical insulators like wood or plastic are also good thermal insulators. Good conductors like copper and aluminum are poor thermal insulators. Metals like copper contain many free flowing electrons on their surface that allow the transfer of thermal energy from one point to another.
Thermal insulation is also affected by the density of materials. A material with low density will act as a good thermal insulator. At a sub-atomic level, this can be explained because materials with low density will have atoms located further apart from one another. Therefore the transfer of energy from one atom to another will happen more slowly and less effectively. This is the reason why air is able to insulate heat better than water, and water is a better heat insulator than solids.