If you place a plastic cover over a cup of hot chocolate it stay hotter longer because the heat is trapped in a material that prevents it from escaping. For instance if you placed a tissue it wouldn't stay hot long because the tissue is made of cloth that has very tiny holes. The heat is carried by heated air which expands and so has lower density than the surrounding air and therefore rises. So if you prevent that heated air rising you prevent the loss of heat. Using a tissue, there isn't much of a pressure difference to force air through holes, though there may be a small amount of percolation. But the tissue would heat up because it is so thin, and the air in contact would be warmed and take away that heat.
<<>> another way that the lid prevents heat loss is that is prevents the liquid from evaporating. Evaporation takes a lot of heat away.