The glass of a greenhouse allows the sun's radiation in, which warms the ground inside, which in turn warms the air above the ground by longwave (heat) radiation. The glass then acts like a barrier to keep the warm air inside from mixing with the cooler air outside the greenhouse.
Since the industrial revolution, human activities have also resulted in an increase in natural greenhouse gases, especially carbon dioxide. An increase in these gases in the atmosphere enhances the atmosphere's ability to trap heat, which leads to an increase in the average surface temperature of the Earth.