Well, according to TIME, there are a handful of theories.
According to the magazine, one theory regarding the yellow paint job can be found in author Jude Stewart book ROY G. BIV, a book about color’s cultural meanings and history. A story that dates back to 15th century Italy claims a man named Francesco Tasso instituted reforms to the postal-system business his family was a part of. One of the reforms was to make the delivery vehicles yellow, since it wasn’t a color that would offend anyone politically.
Stewart states, though, that this tale lies in the “fun, possibly-not-true territory of history.”
Another story dates back to Albert Rockwell’s Yellow Taxicab Company which started in 1908 after Rockwell and his wife Nettie noticed the prominent role of taxi transportation in European cities while on a trip. Rockwell’s second wife suggested the cabs be painted yellow, her favorite color, with a fancy “R” on the door.
By 1910 the vehicles were known as the “yellow taxi” and Rockwell incorporated the Yellow Taxicab Company in 1912, with Robert C. Watson and William M. Lybrand.
New York’s medallion system was then established under the Haas Act in 1937, limiting the number of taxi licenses and only allowing regulated and supervised taxis to pick up riders who hailed them on the street. Manhattan eventually became the main area of operation for the medallioned cabs, yet even though yellow taxis were common they weren’t the only color around (orange, red, and gold were also typical colors as late as 1968).
Thus, in order to help passengers tell the difference between medallion cabs and non-medallion cabs, a law was passed to make all medallioned cabs yellow.
Today, the official color of the yellow taxi cab is Dupont M6284 yellow or its equivalent.
As for the light green cabs that not too long ago began popping up in NYC, those are only allowed to pick up fares in the outer boroughs and northern Manhattan.
For more interesting NYC history, check out: From Tokens To Taps: The Evolution of Subway Fares