Teams classification
Below is an old version of my explanation of the team classification. For a more complete story that I tried to keep up-to-date, see my book about Tour de France rules and statistics.
Origin
Many sources say that the team classification was introduced in 1930. Other sources give winners of this classification from the first Tour, suggesting that it already existed in 1903. The truth is somewhere in between.
In 1909, teams were used officially for the first time. From then on, a team classification could have been calculated. It almost was there: there was a classification for bicycle factories, the Anales politiques et de litterassementires. This was introduced the year before, and given to the bicycle factory that had the four best riders, calculated by summing the positions in the general classification. In 1909, with factory teams, this practically meant that the riders from the factory teams determined the outcome of this classification, because they were better (and better prepared) than the other riders that rode on bicycles from their factory. In 1909, the Alcyon team (consisting of François Faber, Gustave Garrigou and Henri Alavoine) won this classification. (source).
From 1910 to 1914, this classification was reused, and it was treated more and more as a team classification.
In the years after the First World War, riders officially did not ride in teams. But especially in the later years, everybody understood which teams they rode for (the teams that they rode for the rest of the year).
In 1925, the teams returned officially, and there was a team classification, called the "Challenge de régularité, calculated from the times of the best four riders of each team. (source 2) Alcyon was again the winner of this classification.
Also in 1926 (source) and 1927 (source), Alcyon won this classification.
Alcyon again won in 1928. This year, there was also a team prize after very stage, won by adding the times of the three best riders per team. (source) In 1928, there was also a special prize for regional teams (made from touriste-routiers). The Champagne region won this, and it was calculated from the times of the best three riders in the general classification. (source)
Alcyon again won in 1929. (source) Also in this year, there was a prize for regional teams, calculated in the same way as in the year before.
In 1930, the structure of the Tour changed: the factory teams were no longer invited, but national teams were used. The regional teams made of touristes-routiers were used again. The "classement international" was for the national teams, the "classement interrégional" for the regional teams. (source) After this year, the regional classification was removed (or better said: absorbed into the national classification), but the national classification was seen as very successful, probably because the French team was dominating it. This classification was repeated in the next years.
Rules
From 1930 to 1951, the team classification was calculated by adding the times of the three highest ranked riders in the general classification. Also a winning team per stage was calculated in all/most years, by adding the times of the three highest ranked riders per team in that stage.
In 1952, the system changed: the team classification was now calculated by adding the daily team classifications. From now on it was in theory possible that a team would have the first three places in the general classification, without winning the team classification.
In 1955, the leaders started wearing yellow caps, to make the team classification visible in the peloton. (source)
The rules reverted in 1958: the team classification was again calculated as the sum of the times of the three highest ranked riders in the general classification. There still was a daily team classification. (source)
This lasted only for a short time: in 1960, the sum of daily team classifications was used again. (source)
Apparently this classification was not so well received, because in 1961 it completely changed. From now on, times were no longer relevant, but the number of victories (and in case of ties: second places or third places) in the daily team classifications was decisive. Also in 1962, when national teams disappeared and sponsored teams returned, this system was used.
In 1963, it changed again back to the sum of the daily team classifications. This has stayed in place ever since.
The calculation changed a bit in 1978: from now it did not depend on the first three riders, but on the first five riders. (source)
Five was seen as too much, because in 1979 it was reduced to four.
And in 1983 further reduced, back to three.
In 1991, the yellow caps were abandoned.
From 2013 on, the leading was team was allowed (but not obliged) to wear yellow helmets.
I calculated positions in the team classification.