I was a little bit perturbed to be handed what looked like a glass of hot coffee but it turns out that the bottom of the cup is a double layer of plastic trapping air. The trapped air is a good insulator because the air molecules are not joined together - they are actually quite far apart - meaning it is hard to pass extra kinetic energy one to another. Trapping it means that energy transfer by convection is also prevented. Reduced heat flow means that the outside is cool enough to grip safely.