It takes some dexterity to grab a ring from the dispenser as the carousel rotates.
Typically, getting the brass ring gets the rider some sort of prize when presented to the operator.
[2] As the carousel began to turn, rings were fed to one end of a wooden arm that was suspended above the riders.
Riders hoped that the timing of the carousel rotation (and the rise-and-fall motion of their seat, when movable seats were included in the outer circle of the carousel) would place them within reach of the dispenser when a ring (and preferably a brass ring) was available.
It is not clear when the phrase came into wide use but has been found in dictionaries as far back as the late 19th century.