Not looking globally, at all those peoples wearing layers of clothing, it began in the US Military That's correct, the Army and the Navy of the United States.
It seems our uniforms were great stuff. Strong, durable material that held up under all sorts of conditions. That includes deserts and jungles.
Being that those two conditions in particular also tend to make people sweat a lot, a lot of uniforms were rotting from the inside out. Most specifically, the Mexican-American War of 1888. Enlisted men were stripping down to the skin to avoid heat stroke, and military regulations said they had to wear shirts.
The solution was - the sweat rag. Actually, just a shirt to wear between the sweaty body and a uniform. It slowed down uniform rot, and allowed sweaty military men to strip down to an approved tee. Officially approved by the Navy in 1913.
The T in T-shirt is based on it's basic shape, resembling the letter T. "Tee"is acceptable to write, but not a lone "t". F. Scott Fitzgerald was the first to write "T-shirt", and it first showed up in a dictionary short after, in 1920.
Jockey created the modern Tee in 1920, for the USC Trojans football team. It reduced chafing and sores from shoulder pads rubbing against their skin.
In 1948, Thomas E Dewey displayed a printed Tee, with "Dew-it-with Dewey" printed on the front, the first political campaign t-shirt.
But in the 1950s, seeing Marlon Brando and James Dean wearing Tees on the Big Screen pushed them into popular everyday use.