If rear tire is off the ground, the wheel will spin when pedaled.
When wheel is on the ground the pedals will move the chain in any gear but will not move the rear wheel. The chain is not losing contact with any sprocket cogs.
Why doesn't the rear wheel turn?