It had to do with being color blind.Usually, the red light contains some orange in its hue, and the green light contains some blue, for the benefit of people with red-green color blindness, and "green" lights in many areas are in fact blue lenses on a yellow light (which together appear green). In other words by combining 2 colors to make1 those that couldn't see one color had a chance of seeing the other
started in the 1840s by the railroaders. first traffic light was in Cleveland in 1914 with just green and red. in the early 1920s, Detroit had first automatic traffic light which included yellow and that's what we are stuck with today
I was just thinking about this today and I have a few thoughts on it.
Thought #1: It had to be something.
Thought #2: In psychology, green is a delightful color. We like to be able to go, so why not pick a color we like along with an event we like? Red is sometimes a frustrating color and so we picked a frustrating color for a frustrating halt. (I suspect they didn't do this to tease us, but rather because it's natural to pick that order.) Yellow is used just because it's a mix of red and green.
Remember, I'm no law and order professional, just an amateur in psychology. This answer is just a thought of mine.