The color scheme comes from a system used by the railroad industry since the 1830s. Railroad companies developed a lighted means to let train engineers know when to stop or go, with different lighted colors representing different actions. They chose red as the color for stop, because red had for centuries been used to indicate danger. For the other colors, they originally chose white as the color for go and green as the color for caution.
The choice of a white light for go caused an incident in 1914 when a red lens fell out of its holder leaving the white light behind it exposed. This ended with a train running a “stop” signal and crashing into another train. The railroad decided to change it so the green light meant go and a yellow caution was chosen, because the color is so distinct from the other two colors used.
In 1920 in Detroit Michigan, a policeman named William L. Potts invented the four-way, three-color traffic signal using all three of the colors used in the railroad system. Thus, Detroit became the first to use the red, green, and yellow lights to control road traffic.
During the late 1920s, several automated and manual variations were tried, but in 1935, the Federal Highway Administration created “The Manual on Uniform Traffic Control Devices.” This document set uniform standards for all traffic signals and road signs. The current change to LED lights greatly reduces the amount of electricity needed and the bulbs last for years, saving a bundle on replacement costs.