1) When I really need it within a couple of days and can't quickly find it locally
2) When it isn't carried locally (the local retail stock is a lot thinner than 20 years ago)
3) If there is a BIG price difference -- used to be common but now much rarer. As you say, Amazon's prices are often worse than buying locally.
4) When I need it shipped somewhere else. I usually spend Christmas, for example in another city, and it is impractical to bring a bunch of presents. Amazon is good for situations like that.
I dislike Amazon, but they are now so dominant it is hard to avoid them.