Why you have the ozone layer?

because it protects us from the uv rays and it absorbs the solar energy to let the temperature at night good and not so cold