es used as a personal pronoun
The pronoun es is usually used to replace a neuter noun:
Wo ist das Buch? – Es ist in der Tasche. (es = das Buch)
es as the formal subject with impersonal verbs
There are other functions that es can have. Sometimes es does not stand in for a definite noun but takes the role of the subject without having a meaning of its own. This construction is often used in impersonal phrases in which there is no other subject.
Examples of this are sentences or clauses that describe weather phenomena:
Es regnet.
Es schneit.
Es ist sonnig.
Es ist bewölkt.
Es ist neblig.
Here, es stands for a situation or state to which no concrete subject can be attributed.