Greenhouse gases
Greenhouse gases include carbon dioxide and methane.
How greenhouse gases impact Earth's atmosphere
Without greenhouse gases Earth's average temperature would be roughly the same as the moon, i.e. -18°C., and it'd swing wildly between -170°C and 100°C across a day. During the day our atmosphere blocks out the most harmful rays and about 1/3 of visible light, and at night it traps infra-red radiation to keep the temperature higher.
Only gases with electric charges (i.e. more electrons than protons) block solar energy. Most of the atmosphere is made of molecules, like oxygen, nitrogen, and water, that don't have an electric charge (i.e. balanced number of electrons and protons). However some molecules are "lopsided" (i.e. most protons on one side and electrons on the other side of the molecule) and can absorb the energy of infra-red rays - water (H2O), ozone (O3), and nitrous oxide (N2O) are examples.
Carbon dioxide and methane are examples of gases that internally bounce around enough to sometimes become "lopsided" and also absorb infra-red rays. The vast majority of our atmosphere (oxygen and nitrogen) cannot absorb infra-red rays. Despite this, the gases that can absorb this energy can absorb up to 90% of outgoing heat, despite only making up 1% of the atmosphere. These are greenhouse gases. Greenhouse gases trap heat energy leaving Earth's surface and radiate it back towards Earth. Records from ice show that small variations in carbon dioxide produce big variations in temperature.