Tests are used to determine whether someone has learned. Learning at the most rudimentary level is an observable change in behavior. Humans did not always test their children. Just imagine how an adult might have tested a child in ancient times. They might question the child orally, and adjust the question in response to the child's response, facial or body language, “Where should we go to find deer at dawn and why?” Another means of assessment might be to ask the child to demonstrate a skill or knowledge, such as “Which mushroom is poisonous?” Then, as now, we wanted to see if the child had learned. The difference then was that the knowledge or skills were of practical immediate value and the type of assessment was not objective like today's multiple choice monstrosities.
Why do we test today? Ostensibly it is still the same, to see if a child has learning, but now many other social and cultural factors are also important.