Do you hear a "tick" sound every time you spin the wheel anti-clockwise? that's the freewheel mechanism composed by two small parts called "pawls" and when you spin it on that direction, those pawls turn loosely until they find the "dent" in the inner mechanism (the ratchet body), that's when the "tick" sound happens.
!pawls
When you ride your bike, those two pawls do exactly the opposite, they catch the "dents" and force the inner mechanism to rotate! it's wonderfully ingenious and simple at the same time.
!"dent"
I've disassembled and assembled several and it amazes me every time.