What is the reason behind the colors used for different flight categories?
VFR and IFR existed first. LIFR and MVFR were added later. I don't have a source on why magenta was specifically chosen, but red couldn't be used for LIFR because it was already used for IFR and in aviation we like to avoid obsolescence whenever possible.

I haven't been able to dig up exact timeframes for the implementation of IFR (since VFR was the default.) Although the terms VFR and IFR appear in the history of the FAA in the 50's, some references such as FAA's historical perspective cite the piedmont mid-air of 1967 as the source of the modern culture surrounding ATC including IFR rule enforcement.

For more reading on how flight rules came to exist in the US, I recommend an article on gizmodo.