There are "usual" demonstrative pronouns, introducing demonstrative pronouns and correlates which look pretty the same when they appear in a sentence, but they behave different:
demonstrative pronouns in their common usage
They refer to a specific noun in the context. This noun can exist before the pronoun, often in a preceding sentence, which is the most common place. It also can exist after the pronoun, and it even can exist just as an unspoken word in the mind of the speaker and the listeners. Grammatically is important, that the grammatical gender of a demonstrative pronoun must always match with the grammatical gender of the noun to which it refers, even if it is an unspoken word.
Here are some examples:
noun before the pronoun
This is the most common order.
masculine: Ich brauche diesen Löffel nicht. Der ist außerdem schmutzig.
feminine: Ich brauche diese Gabel nicht. Die ist außerdem schmutzig.
neuter: Ich brauche dieses Messer nicht. Das ist außerdem schmutzig.
I don't need this spoon/fork/knife. It's also dirty.
Noun after pronoun
This is allowed, but rare.
Der ist ja völlig verdeckt! Hier, diesen Löffel meine ich.
Die ist ja völlig verdeckt! Hier, diesen Gabel meine ich.
Das ist ja völlig verdeckt! Hier, diesen Messer meine ich.
It's completely filthy. Here, I mean this spoon/fork/knife.
This occurs very frequently in spoken language, but is rare in written texts because it is difficult to put a word in context in a written text without writing it. In spoken language, it is much easier to put a word into context with gestures or other non-verbal techniques without saying it.
The waiter brings a plate of soup, says »So, hier ist Ihre Suppe« and places a spoon next to the guest's plate. The guest takes the spoon, looks at it briefly, then holds it up to the waiter with a reproachful look and says: »Der ist ja total schmutzig!«
The only spoken noun that exists in the context is the female noun die Suppe, but it's clear from the situation, that the guest and the waiter have a communication who's topic is the spoon. And although the masculine noun der Löffel never was said by anyone involved in the conversation, the demonstrative pronoun still refers to it and so the gender of the pronoun must be masculine, because it always must match with the nouns gender.
Of course, this also works analogously with an unspoken fork (»Die ist schmutzig«) and an unspoken knife (»Das ist schmutzig«) that the guest waves in front of the waiter's nose.
demonstrative pronouns when used to introduce something
Das sind meine Bücher.
Das ist mein Arm.
This is a special usage of demonstrative pronouns that has its own rules. It is an exception of what was said before.
When you begin a sentence with »Das ist ...« or »Das sind ...«, and when you do so to introduce what's coming next to the audience, then there is nothing in the context before the introduction is spoken, so there is no noun who's gender the pronoun can take, and therefore the pronoun appears in the default gender, which is neuter.
A young man who lives with his wife in his parents' large house has invited his boss to his home. When the boss enters the house, the man's wife is standing with him and the man introduces her to his boss:
»Das ist meine Frau.«
At that moment, his parents also appear and the young man says:
»Das sind meine Eltern.«
And then he says to his relatives:
»Und das ist mein Chef.«
Note, that this is different form the situation like in »Der ist ja völlig verdeckt! Hier, diesen Löffel meine ich.« These sentences, where the noun Löffel appears after the demonstrative pronoun der is not an introduction of the spoon to the audience. It is a variation of the word »Löffel« existing as unspoken word in the context, like in the example with the guest and the waiter. But then still the noun, to which the pronoun refers, appears as spoken word afterwards.
correlate pronouns (or just »correlates«)
A correlate pronoun is very similar to a demonstrative pronoun, but it does not refer to a noun which always has a distinct grammatical gender, so that the demonstrative pronoun can match with it. Instead a correlate pronoun refers to a whole clause or a sentence. But neither a clause nor a sentence has a grammatical gender. So, the correlate pronoun has no gender to which it could match and so it appears always in a default gender, which is neuter.
The clause or sentence can again stand before the correlate, it can stand after it even exists only as unspoken phrase in the context.
Gestern hat uns der Professor die evaporative Kühlung erklärt, aber ich habe es nicht verstanden.
Gestern hat uns der Professor die evaporative Kühlung erklärt, aber ich habe das nicht verstanden.
Yesterday the professor explained evaporative cooling to us, but I didn't understand it.
Der Professor is masculine and die Kühlung is feminine. So, in the spoken context is a masculine and a feminine noun but no neuter noun. But the pronoun (es/das) is still neuter.
You can have pronouns, that refer to the existing nouns, this is absolutely correct:
- ... aber ich habe ihn nicht verstanden.
- ... aber ich habe sie nicht verstanden.
In #1 you say, that you were unable to understand the professor, and in #2 you say, you didn't understand how evaporative cooling works. Both are legitimate and absolutely correct sentences. But in German you can also express that you were unable to follow the explanation process. Then you don't refer to the masculine professor, and you don't refer to the feminine cooling, but to the act, that is described in the genderless clause »Gestern hat uns der Professor die evaporative Kühlung erklärt«. And in such cases you don't use a personal pronoun nor a demonstrative pronoun who both need a noun to adapt their gender to it. Instead you use a correlate pronoun that does not refer to any noun and therefore is always used in the pronouns default gender which is neuter.
Dieser Kochlöffel ist schmutzig, aber der hier ist sauber.
Here you are referring to a masculine cooking spook that exists in the unspoken context. (It is not the cooking spoon from the main clause, but another cooking spoon.) So, there is a masculine noun to which the demonstrative pronoun can refer, and therefore it inherits this nouns gender.
Das sind meine Bücher.
Das ist mein Arm.
I've talked about these sentences explicitly before.
Es ist Mittag.
This is something different. The word »es« is an expletive pronoun. It does not refer to anything and it does not add anything to the proposition of the sentence. (The proposition is the semantic meaning, i.e. something that can be true or false.) It is there just to occupy position 1 to allow the verb (ist) to stand on position 2.
Es sind Ausländer.
This is different from »Es ist Mittag«! The word »es« in »Es sind Ausländer« is a correlate, that refers to a situation in the context, that has no gender, and therefore the pronoun is neuter.
Der ist Polizist.
Die ist eine Blume.
These are demonstrative pronouns in their common usage, with the referred noun after the referring pronoun.