Of course, one of these three stances may have some kind of merit, and I am going to present a hypothesis that I suspect might be fairly accurate. Let us first consider what grammar is. And for this consideration, we start out with a sort of overview of mistaken understandings of it, so that we can try and come up with a more sensible and accurate notion.
An authority-based notion
Early historical linguists seem to have believed that as civilizations were formed, there was work invested in giving the language a grammar. The notion these linguists really seem to have labored under, is that pre-civilized language lacked grammar, and that grammar only exists as a conscious product of language planning. Thus, uncivilized people lack grammar, or at the very least have very primitive grammar, and civilized people have a cultivated, artificial grammar.
Oftentimes, an extra claim comes along: once the language has been designed and the culture has reached its apex, laziness sets in and the language starts deteriorating, shedding grammar as it goes along.
The problems with this are manifold:
- It turns out that grammars have features that are so abstract, it's only in recent decades we've developed a descriptive apparatus for them - yet these features have been along for quite a while. These features do affect how people speak, yet no one understood these features even existed until fairly recently!
- It turns out languages have acquired new grammar even after the 'apex' of their culture, and even more so - without any actual planning going into it!
- It also turns out we have better models now for understanding what goes on when grammar is generated.
The reason I consider this an authority-based notion of grammar is that it ascribes a kind of authority-status to those who, according to this theory, designed Sanskrit, ancient Greek, Latin, Old Irish, etc. Of course, there is no reason - even within this model - to think the designers met up to design it, they can rather have contributed consciously bit by bit to an ever-growing language. Thus, Ωαζισφασες adds a rule to Greek in 1000BC, and Σοανδσoν adds another rule 160 years later, promptly followed by ὑιζῆς and thus together they all contribute to building the great ancient Greek language. (For those who didn't get the joke-names, they're Whatshisfaces, So-and-son, and Hu-is-hes.)
A more abstract (sort of supernatural) notion
Some seem to just posit that grammar exists, and that utterances either conform to it or do not. This does not explain how this grammar exists or what form its existence takes - is it an angelic being in the platonic spheres or is it a law of physics or what is it? For most purposes - e.g. writing easily understandable texts - this is a sufficient idea! It is wrong, terribly so, but it works in many contexts. It does create a bit of a neurotic approach to correct grammar among some speakers (e.g. 'Is X a word?!') in contexts where understanding would not be hampered even the slightest, but this is also the case with the previous approach as well as the next one.
A clearly authoritarian view
There is finally the view that whatever some authority on grammar says is what goes and basically what grammar is. Thus, grammar correlates with what recognized authorities think. This view runs into problems when the authorities have inconsistent views - which is even possible for one single authority to have - or when we can show that a language adheres to some rule that no authority has ever described or decided. Such a rule definitely belongs to the grammar of the language, yet it cannot be accounted for by the authoritarian view.
Another obvious disadvantage about the authoritarian view is the situation when a new construction is required because no means of expressing a certain thing exists - are all statements expressing such thoughts wrong until an authority has made a pronunciation on how to say it?
A more general and rational view
There may be other views, as well as situations in which the authoritarian view at least makes sense - e.g. if you are trying to write or say something where conforming to a set standard is expected. However, this is a rather specific situation, and we know grammar exists independently of that kind of situation as well.
First, I will go in for a very concrete view of what grammar is. Once the concrete view has been described, I will attempt to formulate models. It is important to realize that models are just tools; we have to use models, though, because of map vs. reality - reality is tricky, and we need to be able to focus on the relevant details in a way where the squishiness of the variables of reality can be partially ignored.
Let us consider what grammar does, where it resides, and finally what this implies as to what it is. When we speak, we have a huge set of somewhat generalized patterns. What does grammar really do? It is patterns we use when parsing and generating linguistic content. Depending on our level of analysis, it can be the patterns taken in isolation, or a description of the patterns and the machine that does the pattern-parsing.
Without these patterns, we couldn't parse statements, nor could we generate them. These patterns also include what we could term statistical patterns. Such a pattern is 'in English, objects are very likely to come after the verb', or in most languages 'certain kinds of nouns are more likely to appear as objects than as subjects of this or that verb'. They are not rules that are etched in stone - sometimes, we will come across sentences that violate such statistical rules.
In fact, it will turn out that even those patterns we may figure are set in stone in fact vary from speaker to speaker. It will turn out that a full description of some given grammar may well be beyond reach. For the moment, we will assume that a grammar of a language is some kind of weighted average of the grammars residing in the minds of the speakers.