A rainbow is not an object suspended at one fixed distance. It is a pattern of light reaching an observer from many water droplets, usually with the sun behind the observer and rain ahead.
The path through a droplet
Sunlight bends as it enters a droplet. Different wavelengths bend by different amounts, separating colors. Some light reflects inside the drop, then bends again as it leaves. Only droplets in the right directions send a particular color toward your eyes, so together they form an arc centered opposite the sun.
Why no two people see quite the same bow
Move your head and the set of droplets contributing to your rainbow changes. A second, fainter bow can arise when light reflects twice inside droplets, reversing the order of colors. The physics combines refraction, internal reflection and dispersion—the separation of wavelengths that a spectrometer also uses in a controlled instrument.
Related: how a spectrometer separates light by wavelength.
