It depends on what type of camouflage you are talking about. The current type, the Universal Camuflage Pattern, was first field tested in 2003-2004. It was chosen and colored to be used in the Middle East; they have different types, but they all are said to be ineffective in non-arid areas. This camouflage type is soon to be phased out. Older camouflage, like that used in Vietnam, are geared towards jungle environments, obviously. The main reason for the switch to camo was the change in fighting styles throughout the ages. Rifle units were wearing green and other ground colors as far back as the 18th century in order to take advantage if their long range capabilities. In the Revolutionary War, line battles and all out rushing were the standard; there isn't any sense in camouflage in a line battle. In the Civil War, the thrown-together uniforms of the average confederate soldier would make a standard uniform hard to follow. The Confederate quartermaster only started mass-producing uniforms in 1862. There was camouflage used by units such as snipers as far back as the Civil War, but camouflage for the average soldier would have been costly and useless, because, once again, large scale battles were the norm. World War 1 brought about the main change; due to artillery and air support (planes became a thing), it actually became important for men to blend in to avoid being seen by recon planes and other unsavory flying machines. To be clear, this was just color, not fancy patterns at this point. During the next World War, they experimented with patterns but solid colors provided better camouflage while moving so they stuck with those. As accuracy and observation capabilities increased, so did the need for camouflage. Vietnam made jungle patterns more useful, since they were in a jungled area. I think I answered your question about the origins of camouflage itself, but the origin of the digitized camo you see now is Canada's CAPDAT, back in 1988. This is about the same time many other countries were developing new camo themselves.