Linguists are always taken aback by the overwhelmingly negative and sometimes virulently expressed reaction they get when stating something that every linguist believes (and linguists do not agree on everything!) in a rather uncomplicated way: Every dialect has a grammar.
"Every dialect has a grammar" does not mean "everything is relative, and let's throw away all the dictionaries, and no one should go to school anymore, and I should be able to wear a bath towel to a job interview if I damn well please." What it means is that all dialects, from the very fanciest to the ones held in lowest esteem, are rule-governed systems. Here are three examples from three different commonly disparaged dialects that illustrate how dialects have grammar.
1. APPALACHIAN A-PREFIXING
One of the most noticeable features of Appalachian English, which has been studied extensively by the linguists Walt Wolfram and Donna Christian, is the a- prefix that attaches to verbs. When people want to mock "hick" speech, they often scatter a-prefixed words around like "a-goin'" and "a-huntin'" and "a-fishin'," but if they don't actually speak the dialect, they usually make mistakes. That is because they don't know the rules of where a-prefixing can apply, and where it can't. Rules? Yes, rules. To someone who speaks an a-prefixing dialect this sounds right: "He was a-huntin'." But these sound wrong:
He likes a-huntin'.
Those a-screamin' children didn't bother me.
He makes money by a-buildin' houses.
It is not the case that a-prefixes can attach to any old word ending in -ing. They can attach to verbs, as in the first example. But not to gerunds (a verb serving as a noun for a general action), adjectives, or objects of prepositions, as in the other examples. The fact that those examples sound wrong to dialect speakers shows that there are conditions on where a-prefixes can go. The fact that those conditions can be described in terms of verbs, gerunds, adjectives, and prepositions show that the conditions have to do with the linguistic structure of sentences. A condition that depends on linguistic structure is a rule. A system of these rules is a grammar. This is what linguists mean when they talk about the grammar of a dialect.
People who speak this dialect don't learn these rules from a book. They know them implicitly, even if they can't describe them, the same way you know "I gave him a dollar" sounds good but "I donated him a dollar" sounds bad (even if you've never heard of linguistic argument structure). Their use of the dialect is not whimsical and random, but governed by those rules. Someone who doesn't follow those rules, e.g., in a hamfisted attempt to mock the dialect, can be said to be speaking ungrammatical Appalachian English.
2. SOUTHERN AMERICAN ENGLISH "LIKETA"
Often features that are seen as sloppy pronunciations of Standard English show themselves on closer inspection to be used in a non-sloppy, highly consistent way — but according to a different set of rules. In the Alabama dialect studied by linguist Crawford Feagin, speakers say things like, "She liketa killed me!", meaning that she just about started to kill me, but didn't. This "liketa" is not just a shortening of "would have liked to"; it's also possible to say "I liketa had a heart attack." "Liketa" is close to being a substitute for "almost," but it doesn't behave exactly like that word either; you can ask "did you almost die?" but not "did you liketa died?" "Liketa" is not just a lazy version of Standard English. You can describe the conditions for its use — the rules of "liketa." As Feagin says, it "occurs in both positive and negative sentences, but not in questions and commands. It may co-occur with the intensifier 'just'; it always occurs in the past." Because rules govern "liketa," it is possible to break those rules, and if you do you can said to be using it ungrammatically.
3. AFRICAN-AMERICAN ENGLISH STRESSED "BIN"
African-American English has a number of distinguishing features, one of them being the use of "stressed BIN," described by linguist John Rickford. It carries the main stress of the sentence and is distinct from unstressed "been." It occurs in sentences like "she BIN married," which does not mean "she has been married." It means "she is married, and has been for a long time." Stressed BIN is like a remote past tense, something that Standard English lacks a simple marker for. It can also be used in places where Standard "been" would not occur, such as "I BIN ate it" (I ate it a long time ago).
There are structural conditions on where stressed BIN can and cannot occur. Its use is governed by rules. As linguist Lisa Green points out, it can't be moved to the front of the sentence for questions (BIN John and Lisa dating?) or used in a tagged question at the end (She BIN married, binn't she?), and it can't be used with phrases indicating a specific time (I BIN asked him bout that three weeks ago). Because there are grammatical conditions for the use of stressed BIN, it is possible to use it the wrong way, as nearly everyone who tries to mock it does.
More explanations of these phenomena and others can be found at the Yale Grammatical Diversity project, the mission of which is to serve as "a crucial source of data for the development of theories of human linguistic knowledge." However you feel about dialects and whether they are worthy of respect, the fact that human ways of speaking always settle into rule-governed systems, all describable in terms of the same set of basic linguistic concepts — that, at the very least, is pretty darn interesting. And frankly, the more you pursue what's interesting about it, the less emotional your judgments about dialects become.