It's an interesting overview of how color came to be encoded on PC-compatible computers. The brief overview is this:
CGA, the Color/Graphics Adapter from the earlier PC-compatible computers, could mix red (R), green (G) and blue (B) colors. So that's eight colors, from 000 Black to 111 White.
Add an "intensifier" bit, and you have sixteen colors, eight colors from 0000 Black to 0111 White, and another eight colors from 1000 Bright Black to 1111 Bright White.
There's a bit more about the background and the bit-pattern to represent colors. Read the full article for more: Why DOS has sixteen colors