Pretty sure Apple sells them off to a third party as users/returned goods at a discount.
A few slip by and get put back on the shelf. Probably when customers lie and say they never opened them, or just due to mistakes.
Apple is putting serial numbers on each case now, so anyone thinking about pulling a switcharoo, might want to think twice
There's a seal on the box to prevent them getting put back if opened.