RGB is an additive colour model (if you add a red, green and a white light together you get white). It’s how your eye works: you have R, G and B cones and they work together to allow the brain to see different colours, each one reacting to light at given wavelengths.
Adding any two R/G/B colours together gives you one of the three in the subtractive colour model. Removing all of them gives you black (ie there is no light).
Red Yellow and Blue (or more properly Cyan, Magenta and Yellow) are used in subtractive colour models, they’re used for print media (and paints) and describe how colour works when you pass white light through [microscopic] layers of another medium (eg paper). Subtractive because when you take away colours, the base colour goes towards transparent (if there is no colour applied, then there is no colour). When you add them together, the colour goes towards black.
Historically, RYB is how it’s been described (historically as in 100s-1000s of years), so even though CMY is more versatile, RYB has hung around. RYB/CMY is also easy to explain visually because you can just chuck some paint on paper to demonstrate it (whereas you need lights to demonstrate RGB).
In all models the above explains why black and white aren’t colours. In RGB, white is just a full spectrum of light rather than individual colours, black is no light. In CMY, white is no colour [on a white background], and you can’t ever actually get to what you’d consider real black (you can just get a perceptually very dark colour by managing to get to something that reflects the smallest possible amount of light).
Note these are all somewhat arbitrary models for describing colour, and there are a lot of different variations on these colour models. But the subtractive colour model (the one you get taught in school) only really applies to stuff like painting/printing (which admittedly includes a vast amount of stuff). With electronic devices, you’re looking at a light source (think of each pixel as three lights, one each of red green and blue), it makes sense to describe it using an additive colour model.
Edit: printed stuff is restricted in the number of colours you can use (just actual physical constraints). Computer graphics nowadays are much less restricted, you can go up to billions of different colours. Which means there are lots of colours that can be rendered on a computer screen that you can’t print. So when working professionally in graphics software, you would normally switch from RGB-based model to a CYM model if designing for print (or you would pick specific colours from a Pantone© palette).
Side note: RGB and the other additive colour models are all ever so slightly…wrong I guess…in various ways in various circumstances: they’re a way to mathematically encode colour, and problems appear in when you try to do calculations with them (for example, if I try to make a gradient from one colour to another using RGB, it’s quite common to end up with a big grey area in the middle which is never what I want). I suppose this happens with subtractive colour as well (think how easy it is to make a horrible brown colour by accident when you’re mixing paints)