Way back in the early nineties most graphics cards (including those on £20K SGI Indy 'graphics workstations') did not have enough memory to render hi-res, true-color images. The work around was to use 256 colours that worked with a look up table and dithering algorithms.
The 256 colours of the 'look up table' could be any of the 2^24 colours you get with a modern PC, however, some of these were reserved for the operating system to use. Typically 32-40 colours were used for window borders, menu text and other screen decoration leaving 216 colours for the application.
With PC applications on an 8 bit display each window/application could have its own color set, particularly with Unix workstations. This could lead to flashing of colours when going from one window to the next - the selected window would look good but the background windows could be a bit weird.
When the web came along with the Mosaic browser (and later Netscape) the browser had to work with the other applications, showing however many images the web designer included on the page. These could be automatically dithered down to the 216 (6 x 6 x 6) 'web safe' colours. Naturally the other page elements (e.g. 'H1 - H6') could also be dithered down to the 216 colours that the palette had available.
If one did not stick to the 216 'web safe colours' (that any browser could render) then the results were unpredictable, a subtle red might get rendered as an unsubtle red etc. As others in this thread have mentioned, 16 bit and true-colour came along for most PCs in the mid-nineties, making 'web safe' less of a problem. However, 16 bit screens used less bits for each colour rather than a look up table, as was the way with 8 bit colour. 5 bits for each of the red, green and blue components gave an approximation of true-colour, but was not really. A given RGB value, e.g. #ABCDEF would not be rendered exactly as #ABCDEF so 'web safe' still had some relevancy if you wanted colours to be the same from PC to PC.