I don't know the full details, but part of it:
- In the store you can walk between the books. This takes loads of room. In the Amazon warehouse, this can be veeery cramped.
- The land value of the store is probably mich higher than the Amazon warehouse land.
- They sell much more, so all costs can be shared across a million orders, instead of across just 10 books sold.