The rules of grammar are not rules in the same sense that the rules of baseball, or chess, or tiddlywinks are rules. The latter are prescriptive: if you want to play those games, they describe how you must play them. (Note, however, that even rules of this sort allow for locally recognized variants.) Rules of grammar, however, are descriptive: they exist to set forth the range of utterances which can be made and understood by native speakers of a language. In that sense, “It’s me” is in fact grammatical — no native speaker of English is going to misunderstand what is meant by it.
Grammar, however, is not the same thing as usage, or as idiom, even though prescriptivist grammarians try to conflate the three. “It’s me” is colloquial usage, or casual written usage; “It is I” is formal written usage, in that a contemporary native speaker is highly unlikely to utter it in normal conversation. Similarly, “ain’t” is grammatical — a native speaker of English will understand what is meant by it — but in terms of usage it is at best colloquial, in addition to being strongly marked for region and class. A good teacher of English will make sure that his/her students are able to recognize and employ standard usage; a really good teacher of English will do so without stigmatizing his/her students’ own speech habits. There are not as many really good teachers of English as there should be.
“It’s me” is also an English idiom — idioms being those bits and bobs of a language that don’t fit into any of the standard tables at the back of the textbook, the ones where the instructor informs the class, grimly, that they’re just going to have to memorize those bits because they don’t make any regular sense. Every language has them: the fossilized snippets of extinct grammar, the vocabulary items borrowed whole from other sources and only halfway bashed into regularity, the words and phrases whose sound or meaning or function has shifted so far from the original that the logical connection has been severed.
Most of the time, when native speakers of a language complain about the grammar of other native speakers of a language, it’s actually their usage that’s being complained about — and thus, indirectly, their social or economic status.