White light, so-called, isn’t really white, but a mixture of red, yellow, green, blue, indigo and violet. It can be dispersed or spread out by a triangular prism. Read Out Your Good Book In Verse, alternatively Richard Of York Gave Battle In Vain, referring to the death of both Richard and his son during the Wars of the Roses at the freezing cold Battle of Wakefield in 1460, are both memory tags to remember the spectral order in decreasing wavelength.
You can blame Isaac Newton for ‘indigo’ which is a kind of dirty purple .
He wanted seven colours, one for each day of the week, the number of known planets at the time and the number of notes in the major musical scale.
Check this image out which shows you how rainbows are made. Separate raindrops disperse white light as shown here. Red on the top, blue on the bottom.