We know that earth receives invisible ultraviolet radiations from the sun. The ill effects of over exposure to sun’s rays (UV rays) are cancer, cataract, skin and other health problem. Nature has provided us with the ozone layer which protects us from the UV radiations.
The second layer of atmosphere called stratosphere, accounts for production of 99% of the atmospheric ozone. The ozone layer would not exist without the sun because it needs UV rays for the production of ozone. Ozone (O3) is made of three atoms of oxygen. It's not a very stable molecule, but it takes a lot of power to create it.
Ozone is produced by a process called ozone-oxygen cycle. Oxygen (O2) gets split into two separate atoms (O) when hit by ultraviolet light. When one of these atoms (O) comes into contact with a molecule of oxygen (O2), they combine to make ozone. The process also works in reverse -- when UV light hits ozone (O3), it splits it into a molecule of oxygen (O2) and an atom of oxygen (O).
During the above processes, ultraviolet radiation gets converted into heat, preventing it from reaching the surface of the earth. Thus the sun helps create ozone layer and the ozone layer protects the earth from the harmful ultraviolet rays.