The phenomenon of naturally warming up earth is called the "Greenhouse effect".
Gases such as carbon dioxide, carbon monoxide, methane, and water vapor present in the atmosphere trap the heat coming from the sun.
They are termed natural greenhouse gases which act like a big blanket around the earth, keeping it warm for making life possible, without these gases the temperature on earth would have fallen to zero values and life would be not possible.
The greenhouse effect refers to the change in the temperature of a planet and the presence of greenhouse gases such as carbon dioxide, methane, and ozone gas that absorb and emits infrared radiation and warms the atmosphere by absorbing infrared radiation emitted by the earth’s surface, by the atmosphere itself, and by the clouds.
As a result of the warmth of the atmosphere, it also radiates infrared radiation in all directions, including downward to the Earth’s surface. The greenhouse gasses trap this heat in the troposphere.