When an object builds up an electrostatic charge, it needs to be ‘earthed’ via a conductor. Electrons flow to/from the earth to balance the charge, this can also occur if you touched a charged object whilst you are earthed. If earthing occurs through a person/animal, it causes an electric shock.