As we know, light is nothing but waves (electromagnetic) of different sizes (Or wavelengths) moving at different speeds. Different wavelengths are perceived as different colours to us. So, visible Light is actually a spectrum of colours moving at different speeds (that also differs in different from one media to another).
Light continues to travel in a straight line, but gets refracted (or scattered) when it changes media, for example from air to water, air to glass, etc. Refraction causes bending of light waves. This bending happens to be dependent upon the wavelength. As a rule, longer wavelengths bend the least and shorter the most during refraction or dispersion. Differential bending causes the separation of colours (and we see the rainbow).
As we know, there are seven colours in the sunlight (VIBGYOR) that get refracted during the rainbow formation (FYI the moisture or water droplets in the air after rain acts as a different media and causes refraction of the sunlight).
Red colour has the highest wavelength, i.e. 620-750nm (and Violet has the least, i.e. 380-450 nm) besides also the lowest frequency. This is why red moves more quickly than the other colours and bends the least (and violet bends the most).