While rainbows have always shown their colors, Sir Isaac Newton was the first that described the spectrum as seven colors. He was convinced that seven was a special number in science. There were seven notes in the scale, seven days in a week, seven known planets at the time, etc. He also saw other strong connections between the musical scale and the visible spectrum, such as the fact that they both were continuous, with one note or color gradually blending into the next.
Since Newton did much of the primary work in the science of color, his use of seven colors became standard. Indigo is not as well known as the others because it is a range of wave lengths that the human eye does not respond well to, and many people can't distinguish it from blue or violet.