Atmosphere is a huge envelope of air. During day time, the sun heats up the layers near the earth's surface more than the layers above the surface.
Now, hot air is optically less dense and cold air is optically more dense.
Hence, the layers of air in the atmosphere have different optical densities.
This causes refraction of light.