Please always give context together with the question. Fortunately Google finds "Heiner, der Eimer" as well as the text.
The reason the text has "es" is because it refers to "das Mädchen" (that's why the context is needed, you don't mention "Mädchen" at all), which is grammatically neuter. The grammatical gender always determines which pronoun to use, though there's a tendency in modern German to switch to "sie" for "das Mädchen" at some stage. In older German you will always find "es".