A GFCI is a "ground-fault circuit interrupter." It measures the current flowing through the hot wire and the neutral wire. If they differ by more than a few milliamps, the presumption is that current is leaking to ground via some other path. This may be because of a short circuit to the chassis of an appliance, or to the ground lead, or through a person. Any of these situations is hazardous, so the GFCI trips, breaking the circuit.