The first instance of a baseball team wearing uniforms for a game came in 1849 when the New York Knickerbockers did so. The uniform consisted of pants, a belt and a shirt. Some teams started placing their team logos on their uniforms about 10 years later. About 10 years after that, the Cincinnati Red Stockings started wearing shorter pants, allowing their socks to show. Naturally, the socks were red.
The National League made an interesting move in 1881, telling its teams that each player had to wear a different shirt color. The color would indicate which position that player played. The only difference between teams was the color of their socks. This experiment lasted just half a season.
By the 1900 season, most teams started wearing two sets of uniforms, one for home games and one for away contests. Normally, clubs wore white at home and gray on the road. This was done simply because clubs might go a significant amount of time on the road without being able to wash their uniforms, and dirt showed up much less clearly on gray uniforms than it does on white ones.
The first team to have numbers on its uniforms was the Cleveland Indians, who did so in 1916. These were only on the sleeves, however. The first time the numbers were on the backs of the uniforms came in 1929 when the Indians and the New York Yankees placed them there.