In ancient Egypt and Sumer, as the first generation of schools were developing, two main types of schooling developed: one for scribes to learn to write and one for priests-to-be to prepare for priesthood. Pupils needed to be extraordinarily wealthy to go to school -- it cost a fortune! At the time, students would learn only what they came in for: writing or prayer. In China, schools were all about morality. While study halls existed throughout the ancient world, standardized testing had yet to be invented.
The first real standardized test took place in China in the first century CE, but it wasn't used for school. Citizens, especially lower-ranked ones, took these standardized tests to prove to the higher-level ranks that they were capable of a governmental position. In 1806, the British did a very similar thing. The British government conducted tests for governmental candidates to take as part of the selection system.
Next, during the Middle Ages, Europeans' lives were no longer fun. Life was just about survival. Therefore, schools mostly died down. But not completely. Rich Christian Europeans wanted their offspring to be educated in Christianity and the Bible and were wealthy enough to achieve this education however they wanted, which allowed a few Christian schools to thrive. Tests were not used very much in these schools.
In the 1850s, universities in the United Kingdom noticed that standardized testing had been beneficial in the political industry, so they adopted the practice for education purposes. For a while, tests had been oral, but there was found to be subconscious bias based on who was taking the test, so many switched to written tests. In the United States, standardized tests were introduced as a way of "grading" the teacher's teaching skills, rather than a student's learning skills.
As standardized tests became more popular, it was becoming more and more difficult to score them accurately. It could take months to receive a grade without any errors. In 1935, IBM started using computerized grading technology, which was speedier and more reliable. For a while, IBM's technology was expensive and difficult to use, but as time went on it became more accessible, like Scantron. In the 1980s, this technology was further improved by tests taken fully on the computer, like what many of us experience now.