It’s explained pretty well in Optical Physics for Babies. Take a peek in the kids books section next time you’re at a book store. It also explains double rainbows, and why the second one has the colors in reverse order and is always more faint. This is a detail they got wrong in my favorite episode of Bluey: Rain.