To address the problem of horse-drawn carriages and pedestrians crowding the streets of London, John Peake Knight suggested taking the railroad method for controlling traffic.
The first traffic signal was thus installed on December 9th, 1868.
Click the link to get more details on the history.
As for what lies ahead...
Imagine a world where traffic signals are nonexistent.
A future where autonomous cars are in communication with each other and engage in "slot-based" intersections, "in which cars, instead of stopping, automatically adjust their speed to pass through the intersection while maintaining safe distances for other vehicles."
And as I think about the "slot based" idea from MIT
, I predict that traffic lights may become nonexistent within the next couple of decades.