Light from the sun comes into the atmosphere of our planet and travels to the rain clouds.
The rain clouds are clumps of rain drops, which have evaporated from the surface of the sea and condensed into big soggy clouds.
When light from the sun hits the rain drops at certain angles it starts to wriggle around all of the molecules in the raindrop.
When light travels a bit slower than usual it starts to bend.
White light contains every single colour of the rainbow, and they all travel at the same speed but have slightly different energies.
The amount the light bends when it is inside the raindrop depends on the energy of the light. red light bends a bit less than blue light, so when the light comes out of the raindrop at all of the different angles the rain bow goes from red to yellow to pink to green…
We can work out all of the angles that this will happen at using some really neat maths and equations.