A rainbow appears when sunlight and rain meet. You usually see one when the sun is behind you and rain is falling in front of you. That is why rainbows often show up after a storm, just as the sun comes out.
Sunlight looks white, but it contains many colors. When light enters a raindrop, it bends. Then it bounces off the back of the drop and bends again as it leaves. Each color bends by a slightly different amount, so the colors separate.
Millions of drops do this at the same time, and your eyes see a curved band of colors. The order is always the same, with red on the outside and violet on the inside.
A rainbow is really a full circle. From the ground, the horizon hides the lower half. From a plane or a high mountain, you can sometimes see the whole circle.