This answer is the equivalent of answering "Why is the sky blue?" with "Because it's not red." Styrofoam is a good insulator because it is actually composed of tons of air pockets. Air is a poor conductor of heat due to the distance between molecules reducing the rate of heat transfer. If you understand the way window blinds work to prevent heat loss/gain, styrofoam works in the same way on a smaller, more numerous scale.