I am sure we have all heard this before but what exactly does it mean? When someone says "eat the rainbow," they're trying to explain, in a simplified way, that the colour of your food can tell you a lot about its nutritional value, and eating a variety of colours is one sure method to get as many of those vitamins and minerals as possible (and eat a broad, diverse amount of food in the process.)
The key here is to note that certain colours of food indicate an abundance of specific nutrients. For example, yellow and orange fruits and vegetables (citrus fruits, gourds, for example) are abundant in vitamins C and A. Green fruits and veggies (kale, spinach, asparagus, avocado) are high in vitamins K, B, and E. Purple produce on the other hand (eggplant, red cabbage, grapes) are high in vitamins C and K.
The reason you can tell these from looking is because plants often derive their colours from various phytochemicals found in them. Those chemicals then offer you different nutrients when they're eaten. That's the root of "eating the rainbow."
In short, adding a variety of colourful produce to your diet is an easy way to get a lot of vitamins and minerals without putting in too much effort beyond selecting a bunch of colours.