Answer: Sunlight is refracted, split into colours and internally reflected inside tiny water droplets, and the coloured rays that come out form the rainbow.
After rain the air contains many small spherical water droplets. When a ray of sunlight enters a droplet, it is refracted at the surface and, because different colours are refracted by different amounts, it is dispersed into its seven colours. The ray then strikes the inner surface of the droplet and is totally internally reflected back. As it comes out of the droplet it is refracted again, and the colours emerge at slightly different angles (red about 42º, violet about 40º). The observer, with the sun behind him, sees these coloured rays coming from different droplets as a band — the rainbow.