Theory:

Why does dispersion occur?
Splitting white light into its seven constituent colours (wavelength), by passing it through a transparent medium is known as dispersion of light.
 
Wavelength_of_light.jpg
 
The light of different colours present in white light has different wavelengths, and they travel at different speeds in a medium.
 
728px-Rayleigh-verstrooiing.jpeg
 
You know that the refraction of a light ray in a medium depends on its speed. As each coloured light has a different speed, the constituent coloured lights are refracted at different extents inside the prism. Moreover, the refraction of a light ray is inversely proportional to its wavelength.
 
Thus, the red coloured light, which has a large wavelength, is deviated less while the violet coloured light, which has a short wavelength, is deviated more.
Reference:
https://commons.wikimedia.org/wiki/File:Wavelength_of_light.jpg
Reference:
https://commons.wikimedia.org/wiki/File:Rayleigh-verstrooiing.jpeg