Because at the late 19th century firearms (rifles) became increasingly deadly, reaching their maximum fire range (up to 1500-2000m, Mauser 98, for example), not to mention introduction of machine guns with high rate of fire (around 600 rounds per minute - Maxim guns). In following conflicts it became obvious how fatal for soldiers can be bright colored uniform or any other gear as they were perfect targets for enemy snipers, armed with new rifles firing bullets with smokeless gunpowder (therefor hard to detect their position). As result khakis (meaning dirt/soil in Hindi (?)) was introduced in Britain's colonial army's around 1870-1880. French was the last who stick to bright colors - check for french red pantalons in WW1.