Different colors of light bend through different angles with respect to the incident ray as they pass through a prism. The red light bends the least, while the violet bends the most. Thus, the rays of each colour emerge along different paths and thus become distinct. This is the cause of dispersion of white light passing through a glass prism.
Isaac Newton used two glass primes, with one prism in inverted position to show that white light of the Sun contains seven colors. The set-up has been shown below:

When white light of the Sun passes through the first prism, it gets dispersed into seven colors. When all the seven colors of the spectrum were passed through the second prism, Newton found a beam of white light emerging from the other side of the second prism. This observation gave Newton the idea that the sunlight is made up of seven colors.