Have you ever noticed that soup, chili, cakes etc taste even better the next day? Why is that? When foods are a combination of ingredients, flavors combine and accent and enhance each other. A coffee bean is a seed that contains over 1700 compounds - oils, starches, alkaloids, cellulose, acids.... When coffee is roasted those compounds change and recombine. Starches become sugars, oils and alkaloids attach, acids and cellulose accent and flavor the bean.
If the coffee is roasted light the sugars don't caramelize as much and the acids are more pronounced giving rise to a more fruity flavor. When coffee is roasted dark the sugars become more chocolate, caramel and toffee accented by the bitter flavor with most of the acid neutralized.
Another by product of roasting are gases such as CO2 that are trapped in the lattice like organic cell structure of the un-ground bean. CO2 has a flavor that is only offset by a lot of sugars, otherwise it can have a soda like effect on the delicate brew.
It takes about 24-48 hours for the bean to release these gases depending on how dark it is roasted. A darker roast will gas off faster because the cell structure is so fractured. A light roast Ethiopia or Brazil may take three days to sweeten. And on dark roasts you will notice the oils are pushed out and the bean becomes shiny. But those oils will start to oxidize quickly and can mellow the flavor of the bean, or if left exposed, will dull quickly.
So the peak flavor of most coffees is 1-2 days after roasting and for about seven to ten days if kept airtight. The CO2 release creates a positive pressure in a closed container helping to slow oxidation.
For example an avacado or banana when picked is green and hard and lacks buttery sweetness. A week later the compounds transform and then another week and the fruit turns dark and loses flavor.
So the answer is you want to buy fresh right out of the roaster coffee, start enjoying the next day and use it up within seven days. That's why we sell half pounds and encourage you to buy what you need for the week.
If you buy grocery store coffee it may be 3-6 months out of the roaster and the flavors will be dull. The exception may be very dark roasts that have the main attribute of being bitter.