This is from an article on sports injuries, but I thought it generally relevant:
Many foot injuries are, in fact, the result of wearing the wrong shoes or the wrong shoe size. Studies have suggested that Americans too often wear shoes that don’t fit, and athletes are no exception. Shoes that are too narrow through the toe box contribute directly to the formation of blisters and bunions. Those that are too short lead to hammertoes and blackened nails, and those in which the flex point of the shoe doesn’t hit exactly at the flex point of the foot can cause pinched nerves and stress fractures. To ensure that your shoes fit, shop at the end of the day, when feet are at their largest, and have your feet measured.
To “shop at the end of the day” I would add, “shop when you have patience”. The biggest shoe mistakes I’ve made have been when I’m in a hurry.