The seven colors are a consequence of us having 3 distinct photosensitive pigments in our eyes which aren't evenly spaced in terms of the wavelengths to which they are sensitive. If they were perfectly spaced we'd have 6 colors: Red, Anti-dark-blue=Yellow), Green, Anti-red=Cyan, Dark-blue, and Anti-green=Magenta. However because of the shift, what we consider to be true blue is somewhere between dark-blue and cyan, so we have Indigo which is halfway between True-blue and Red, Orange which is Anti-true-blue, magenta is blue-shifted into violet, and we forego cyan as one of the major colors.
Note that different cultures do not actually agree on 7 colors in the spectrum or which colors they are. For example some languages consider green to be a shade of blue or vice versa, or green to be a shade of yellow. Some only distinguish between hot (red-yellow) and cold (green-blue) colors. There are also some non-spectrum basic colors, for example english considers light-red (pink) and dark-orange (brown) to be basic colors, whereas a dark green is just a shade of green; and this also varies by culture.
Note that different cultures do not actually agree on 7 colors in the spectrum or which colors they are. For example some languages consider green to be a shade of blue or vice versa, or green to be a shade of yellow. Some only distinguish between hot (red-yellow) and cold (green-blue) colors. There are also some non-spectrum basic colors, for example english considers light-red (pink) and dark-orange (brown) to be basic colors, whereas a dark green is just a shade of green; and this also varies by culture.