The explanation for red is simple: it has the longest wavelength in the spectrum of visible light, so it’s easier to see from a distance.
A red signal is visible from 10 kilometers away. Yellow has a shorter wavelength and may be seen from 5 kilometers away. Green, on the other hand, is only observable from 3 kilometers away.
Far more important to see the red, forbidding signal from afar than the permissive one.