A summary of the trichromatic eye
The most important thing our eyes do is orient us in three dimensions. The back of our eyeball is covered in millions of rods and cones for this purpose and serves us very well. The cones respond to color, but only red, green and blue (for the sake of simplicity). When we see a color that excites a mix of these receptors, our brain perceives a color within the rainbow.
What's interesting is that, because we are all relatively colorblind, a fluorescent light with a phosphor coating mix that emits red, green and blue will look white to us.
Even so, being on the beach is more pleasant because the sun emits the full electromagnetic spectrum, including colors outside of the rainbow such as ultraviolet, infra red, microwaves, etc.
I thought the primary colors were red, green and blue?
Only, arbitrarily, because of the receptors in the human eye. If the receptors responded differently, or to more wavelengths, there would be more primary colors.