This is called Anti-aliasing. It is to make images on screen appear smoother than is normally possible.
I may be incorrect on this part, but I think that the colors (instead of greyscale) is part of the subpixel sampling , which is a more advanced version of anti-aliasing..
sub pixel antialiasing. the individual pixels of your display are made up of (usually horizontal) "sub pixels" of red green and blue, and with clever use of colors your OS can triple the resolution of your text by individually turning those sub pixels on and off
Anti-Aliasing is a different technique that's makes sharp edges look softer by adding more grays, but generally it'd not add other colors as you see here. We also don't generally apply AA to small text as we actually want it to look crisp.
Sub-Pixel Rendering exploits the fact that each pixel of a typical LCD is made up of three color in a horizontal row.
If you had a perfectly white screen and wanted to add one black dot, the simplest way is to turn off the RGB of a single pixel. However you could also get the same effect by turning off the GB of one pixel and the R of the next pixel. This allows you to move the dot by 1/3rd of a pixel. This is what get exploited to make text more legible.
Related question: is what’s happening here similar to how on old Apple computers, if you look closely at white text, you can clearly see green and purple pixels within it?
Nope. Apple used its own sub pixel rendering approach - that wasn’t ClearType. Apple emphasised fidelity of letter spacing - for layout designers - which made fonts at small size famously ‘soft’ or fuzzy. I rather liked the effect, others didn’t.
They nuked in in MacOS Mojave with the rise of Retina displays