Heat is transferred by 3 processes, conducation, convection and radiation. Having a vacuum layer stops heat being transferred away from the coffee by conduction. Conduction works by air molecules bumping into eachother and transferring some of the energy they have, therefore if you remove the air then you stop energy/heat being taken away in this way which helps keep the coffee warmer for longer.