You're telling a friend an amazing story, and you just get to the best part when suddenly, he interrupts, "'The alien and I,' not 'Me and the alien.'" Most of us would probably be annoyed, but aside from the rude interruption, does your friend have a point? Was your sentence actually grammatically incorrect? And if he still understood it, why does it even matter?
From the point of view of linguistics, grammar is a set of patterns for how words are put together to form phrases or clauses, whether spoken or in writing. Different languages have different patterns. In English, the subject normally comes first, followed by the verb, and then the object, while in Japanese and many other languages, the order is subject-object-verb.
Some scholars have tried to identify patterns common to all languages, but apart from some basic features, like having nouns or verbs, few of these so-called linguistic universals have been found. And while any language needs consistent patterns to function, the study of these patterns opens up an ongoing debate between two positions known as "prescriptivism" and "descriptivism." Grossly simplified, prescriptivists think a given language should follow consistent rules, while descriptivists see variation and adaptation as a natural and necessary part of language.
For much of history, the vast majority of language was spoken. But as people became more interconnected and writing gained importance, written language was standardized to allow broader communication and ensure that people in different parts of a realm could understand each other.
In many languages, this standard form came to be considered the only proper one despite being derived from just one of many spoken varieties, usually that of the people in power. Language purists worked to establish and propagate this standard by detailing a set of rules that reflected the established grammar of their times. And rules for written grammar were applied to spoken language as well. Speech patterns that deviated from the written rules were considered corruptions or signs of low social status, and many people who had grown up speaking in these ways were forced to adopt the standardized form.
More recently, however, linguists have understood that speech is a separate phenomenon from writing with its own regularities and patterns. Most of us learn to speak at such an early age that we don't even remember it. We form our spoken repertoire through unconscious habits, not memorized rules. And because speech also uses mood and intonation for meaning, its structure is often more flexible, adapting to the needs of speakers and listeners. This could mean avoiding complex clauses that are hard to parse in real time, making changes to avoid awkward pronunciation, or removing sounds to make speech faster. The linguistic approach that tries to understand and map such differences without dictating correct ones is known as descriptivism. Rather than deciding how language should be used, it describes how people actually use it and tracks the innovations they come up with in the process.
But while the debate between prescriptivism and descriptivism continues, the two are not mutually exclusive. At its best, prescriptivism is useful for informing people about the most common established patterns at a given point in time. This is important not only for formal contexts, but it also makes communication easier between non-native speakers from different backgrounds. Descriptivism, on the other hand, gives us insight into how our minds work and the instinctive ways in which we structure our view of the world.
Ultimately, grammar is best thought of as a set of linguistic habits that are constantly being negotiated and reinvented by the entire group of language users. Like language itself, it's a wonderful and complex fabric woven through the contributions of speakers and listeners, writers and readers, prescriptivists and descriptivists from both near and far.