In the days of 8-color displays (or 16, where the the second half was just brighter versions of the 8), I never saw a pattern in the order the colors came in for things like ANSI X3.64 codes. I assumed they had their small set of colors but the order was arbitrary.
But 8 is how high you can count in three bits: one bit each R, G, and B. The direction may differ between implementations; looks like ANSI X3.64 has Red as the lowest and CGA has Blue as the lowest. But the order of the colors just comes from counting up in binary.
0 0 0 - black 0 0 b - blue 0 g 0 - green 0 g b - cyan r 0 0 - red r 0 b - magenta r g 0 - ~yellow~ brown?