When you earth a charged object you're creating a physical path between this object and the ground so it loses its charge. To begin with the object is charged due to having extra or fewer free electrons. When you earth it, electrons can flow through the path to or from the object. This means the amount of electrons in the object will return to normal and the object will lose its charge.