A bit more detail:
Don't get confused by the common description that the GFCI senses the difference between the hot and neutral currents. It senses the differences among all of the conductors by passing all of the conductors through a ring with a small coil wrapped around it; a current transformer.
If any current goes through the ring but does not come back through it, a voltage developes on the small coil, and it's analyzed and amplified, and trips the device. For current to pass through and not return, it must leak to earth or another grounded surface, possibly through a body.
The electrical supply has to be grounded for the leakage current to want, and be able, to travel through the body, whatever it's in contact with, and to the grounded supply conductor. It's ironic: the grounding connection that makes the device necessary is also what enables it to function.