A rainbow involves no object. There is no arc of coloured material hanging in the sky. What you are seeing is the combined optical output of a large number of individual water droplets, each returning one colour of light to your eye at a precise angle. Move a few metres sideways, and you are seeing a different set of droplets entirely — though the rainbow looks the same from your new position, because the geometry has not changed.
What happens inside a single raindrop
When light from the sun enters a raindrop, three things happen. First, it refracts — it bends — at the air-water interface. Second, it reflects off the back of the drop. Third, it refracts again as it exits. The two refractions are where the colour separation occurs.
Refraction bends light because it travels at different speeds in different media. The ratio of those speeds is the refractive index. Water's refractive index varies slightly depending on the wavelength of light: red light is slowed less than violet light, so red light bends less when it enters water and again when it exits.
The result is that different wavelengths exit the raindrop at slightly different angles. Red light exits at roughly 42 degrees from the incoming direction of sunlight. Violet light exits at around 40 degrees. The other colours — orange, yellow, green, blue — emerge at angles in between.
The key point is that these are not the angles at which light exits most strongly for a given wavelength — they are the angles at which the concentration of outgoing light is highest. The geometry of the sphere creates a caustic: a region where many slightly different ray paths converge, concentrating the light. The rainbow angle is where this concentration peaks for each colour.
From a single drop to the arc you see
Your eye receives red light from every raindrop that sits at approximately 42 degrees from the anti-solar point — the point in the sky directly opposite the sun from your perspective. Violet light reaches you from droplets at 40 degrees. The other colours come from droplets at intermediate angles.
These angular conditions define a cone around the anti-solar point. Where that cone intersects the curtain of rain, you see a coloured arc. The arc is a cross-section of the cone, and its shape — an arc of a circle — follows directly from the geometry.
This is why the anti-solar point matters: the rainbow is always centred on it. Since the anti-solar point is directly opposite the sun, and since you need the sun to be behind you for a rainbow to be visible, you can only see a rainbow when the sun is relatively low in the sky. When the sun is high, the anti-solar point is below the horizon, and so is the rainbow — or rather, it would be visible if there were rain there and you were high enough to see below the horizon, which is why rainbows seen from aircraft can form complete circles.
The secondary rainbow
A secondary rainbow — higher in the sky, with its colours reversed — appears when light reflects twice inside the raindrop rather than once. The double reflection both moves the angles outward (to around 51 degrees for the secondary bow) and reverses the sequence, so violet appears on the outside and red on the inside, the opposite of the primary bow.
The region between the two bows — between 42 and 51 degrees — is noticeably darker than the sky outside the secondary rainbow. This dark band is called Alexander's dark band, after the Greek philosopher who described it. It is dark because there are no droplets at those angles that return light toward your eye by either one-reflection or two-reflection paths. The area inside the primary rainbow is, conversely, brighter than average for the same geometric reason: scattered light from the interior of droplets contributes there.
Why some rainbows are brighter or wider than others
The size of the raindrops affects the appearance of the rainbow more than is commonly appreciated. Large drops — above about 0.5 millimetres diameter — produce vivid, well-defined bows with clear colour bands, because the geometry is precise and the droplets hold their spherical shape well. Very small drops, like those in mist or fog, produce what is called a fogbow or white rainbow: the individual colour arcs overlap so much that they wash out into a faint white arc.
The brightness of the bow also depends on the concentration of droplets in the rain curtain and on the angle of the sun. Near sunrise or sunset, the sun's light travels through more atmosphere and is redder, which shifts the rainbow's colours toward the red end and can produce vivid red-dominated bows that are somewhat unusual to see.