The history of this topic in the US is long and complicated. It differs from state to state, and also between rural and urban areas. In rural areas before about 1850, teachers were in short supply; a prospective schoolteacher had to have a very basic education, and also would have to pass an oral exam administered by the local school board. In the second half of the 19th century, cities began to "professionalize" teaching. First there were "normal departments" within high schools, and later these became independent normal schools. Around 1900-1930, there started to be schools and colleges of education within universities, and eventually many of the more prestigious ones became graduate schools of education. As early as 1905, California required five years of college for prospective teachers.
One can read all this as simply a gradual raising of professional standards, and a lot of these changes did coincide with the great era of progressivism. On the other hand, there were certainly winners and losers in the process, and one can tell an economic story. Supply and demand fluctuated. For example, during World War I, many women left the teaching profession to take the better-paying jobs vacated by men who had been drafted. This led to a shortage of teachers, and teachers' pay went up. During the Depression, there was an oversupply of teachers, and credentialing was used by many districts to control the supply.
Economic liberals such as Milton Friedman have argued that the proliferation of licenses (for morticians, auctioneers, cosmetologists, ...) allows the profession to set up a cartel similar to a medieval guild, so as to artificially limit supply and drive up prices. But I'm not sure that this argument applies well to high school teachers. If it did, you would expect that the credentials would have been created at the behest of teachers' unions. Teachers unions have existed for a long time (e.g., the California Teachers' Association since 1863), but it was only relatively recently that they became the political behemoths that they are in a state like California, where CTA is described as the fourth and most powerful branch of the state government. It wasn't legal for teachers' unions to carry out collective bargaining until about 1960, which is many decades later than the creation of certificates.
My best read on the history is that credentialing was driven by the institutional self-interest of the schools providing training to teachers, as these gradually evolved from normal departments of high schools to graduate schools of education. These institutions employed a lot of professors and administrators, and the livelihood of those people was crucially tied to requiring specialized education coursework for prospective teachers.
Taking California as an example of the current system, if you want to teach high school math, you need a single-subject teaching credential. This requires the following:
A bachelor's degree.
College coursework in education, which is often taken while the prospective teacher is an undergrad.
Passing a standardized test of basic skills (CBEST).
Passing a standardized test showing competence in math (CSET).
The above requirements get you a five-year preliminary credential, after which you need to jump through more hoops (education courses or testing) to get a permanent credential.
I would assume that anyone well qualified to teach math would easily satisfy requirements 1, 3, and 4. But the evidence does not provide much support for the requirement of educations courses. A study by Goldhaber using a a value-added methodology finds that although there are huge differences in effectiveness between teachers, only about 3% that variation is explained by objectively measurable factors including education and experience. In defense of the people who originally set up the credentialing system, it should be pointed out that this evidence is very recent, and there was probably no reliable evidence for or against the effectiveness of education coursework at the time when the requirements were set up; Goldhaber discusses the earlier studies, which were flawed methodologically.
Sources I read:
"The dubious case for professional licensing," http://economix.blogs.nytimes.com/2013/10/11/the-dubious-case-for-professional-licensing/?_r=0
Angus, "Professionalism and the public good: a brief history of teacher certification," available online by googling
Goldhaber, "The mystery of good teaching: surveying the evidence on student achievement and teachers' characteristics," http://educationnext.org/the-mystery-of-good-teaching/