A rainbow is a natural spectrum appearing in the sky. It is caused by dispersion of sunlight by tiny droplets present in the atmosphere after a rainfall. The tiny droplets produce dispersion in the incident sunlight and then total internal reflection and then refraction, as shown. Due to these phenomenon, different colours reach the observer at different angles and a rainbow is formed.