The problem is compounded by the fact (or at least long-held claim) that dealers make most of their money on accessories, ammo, clothes, cases, scopes, and other incidentals, not really on the guns they sell, which only account for a small portion of their income.
So when the only thing you HAVE to go into the store for is the lesser part of their revenue, and they can't possibly, POSSIBLY compete with the enormous inventory of gun accessories, ammo, clothes, cases, scopes, and other incidentals available online at the click of a button, it's a tough business.
One might say that customer service, assistance with choices and options, and the depth of knowledge available at your local gun shop is what REALLY keeps folks coming in the door and dropping their money. But...well, the other great truism about gun shops is in regards to the "legendary" helpfulness and customer service the industry is plagued by.
A good shop is worth a lot.