We get those rules from the speech of the upper middle class. The rules are pretty much set by the publishing industry of the major cultural center of a given language. For Americans it is the Eastern publishing establishment of New York and Boston. Schoolteachers do not invent these rules, though they often do not understand the class implications of them. Prescriptive grammar was invented for most European languages in the eighteenth century.
Most people naturally change their speech to fit the groups they are comfortable with.
The first thing is that you have broken one of the descriptive rules of English. You know you have done this when people know the words you are using but don't understand what you are saying because of a strange word order or bad verb tense formation. These errors are idiosyncratic and often happen only once per error, perhaps when you are tired and your tongue tangles. The other kind of error is a violation of the prescriptive rules of a language, that is, the rules of Standard English. These are the rules you worked workbooks about in junior high school.