An age old question. The answer mostly boils down to the molecules responsible for aromas. A lot of what humans interpret as smell comes from aromas that we smell from the food or drink we’re partaking in (ever noticed how when you have a cold and can’t breath through your nose how food often loses it’s flavor?).
If a bag of coffee is left closed it gives the volatile aromas time to work their way from the interior of the bean outwards (and into the open air of the bag where it’s sealed providing the rush of smell when the bag opens). To that point, when a whole bean is ground it allows those aromas that were trapped inside the bean out.
Bags that are left open allow these aromas to easily evaporate and over time much of what we interpret as taste will go with it.