Carbon dioxide is the primary greenhouse gas responsible for trapping heat in Earth's atmosphere through the greenhouse effect. It is produced by burning fossil fuels, deforestation, and various industrial processes. Oxygen, hydrogen, and nitrogen are not greenhouse gases as they do not absorb infrared radiation effectively.