How does the Sun warm Earth?
There are a number of ways in which heat can be transmitted, including convection, conduction and radiation. Sun's rays travel through the space by radiation (since there is no medium for heat conduction), these rays travel to earth's surface and heat it. The hot earth's surface starts emitting infra-red radiations, which are trapped by the atmosphere, thus heating the earth.
This effect of infra-red radiation being held in by Earth's atmosphere, the effect that significantly adds to Earth's habitable temperature maintenance, is now known as the greenhouse effect. The greenhouse effect now refers to a system where solar light can enter but infrared radiation can't escape the atmosphere, thus heating the entire "greenhouse" or Earth in this case.
The greenhouse effect was first brought to public notice in a negative association with harmful levels of greenhouse gases in the atmosphere but is now used as a general scientific concept to explain Earth's solar warming. The greenhouse effect is brought about by minor constituent gases of our atmosphere, including carbon dioxide, methane, as well as water vapors. These gases are called greenhouse gases and are also implicated for their role in global warming and global climate change when they collect at increasingly high levels.
Hope this helps.