Answer:
Styrofoam's composition is mainly air. This makes it very hard for heat to flow through it, making it one of the best insulators, since it minimizes convention and conduction. By encapsulating air in small cavities, it prevents heat from escaping, thus keeping the hot chocolate warm. On the opposite, materials like metal don't insulate heat energy enough, which means they're bad insulators.