A roller-coaster cart released from rest trades height for speed, and energy conservation tells you its speed anywhere on the track. Around a loop, that speed has to supply the inward acceleration v²/R. At the top, gravity already pulls inward, so the cart needs just enough speed that the track still has to push; if it isn't fast enough, the track goes slack and the cart falls off.