So what is a grammar and what is it for? There are several different perspectives on potential answers to this question:
Concentrating on the linguistic answer, the task of a grammar is to summarise, i.e. in scientific terms, to generalise over, these kinds of information. The generalisations are formulated as rules.
First, the task of the rules, or generalisations, from a scientific point of view, is to predict what is the range of possible grammatical words, sentences, categories and structures in a given language. Some words and sentences are possible in English, others are not - for example, bnik, pfrothk, ngo are not possible words of English, and "play will Sunday Brazil Germany on" is not a possible sentence of English.
If the rules are formulated precisely and according to well-understood principles, then languages can be compared precisely in terms of how similar or different they are. In this way, our understanding of ``how people function'' can be increased.
Second, by comparison of different grammars for languages the range of possible grammars in human language as a whole can be described, and generalisations over these can be formulated as hypotheses about universal principles. This is a particularly interesting question, because in effect these hypotheses about universal principles predict what it is possible for a child to learn.
In other words, words in human languages may follow certain patterns (have certain structures), sentences in human languages may follow certain patterns (have certain structures), but other patterns or structures are not possible. So patterns such as ``SUBJECT-VERB-OBJECT'' are quite common, in languages of the world. The orders ``SUBJECT-OBJECT-VERB'' somewhat less common, ``VERB-SUBJECT-OBJECT'' still less common, and other orders such as ``OBJECT-VERB-SUBJECT'', ``OBJECT-SUBJECT-VERB'', ``VERB-OBJECT-SUBJECT'' are far less common except under special conditions.