Is fresher better?
For the most part, yes! Fresh roasted coffee tastes significantly better than many grocery store coffees, which have been mass produced and left sitting on the shelves for months at a time. However, like wine, coffee can also taste better with age; to a smaller extent. Where wine could take years to reach its prime, coffee takes only days. This will be discussed in more detail below.
The main processes that affect coffee freshness/staleness are degassing and the loss of aromatics with oxidation. You want to find the balance between each process.
So what is degassing?
Degassing is when the gases, mainly CO2, that are formed within coffee during roasting, start release. Immediately after coffee is roasted it begins degassing, 40% of the bulk degassing occurs within the first 24 hours, then slowly afterwards for the next 2-3 weeks. Coffee degassing is what creates the beautiful "bloom" seen with pour over coffee or the crema seen on top of a freshly pulled espresso shot.
Despite the notion of fresher being better, most roasters believe coffee needs to go through a "resting period". During the time of initial degassing, many roasters consider the coffee to be "too fresh", as the flavour of the coffee brewed can be negatively affected. After the coffee has "rested", it will brew more evenly, with more balanced flavours, which don't overwhelm the pallet. It isn't easy to determine exactly when the coffee is at its peak state; dark roasts degas faster than light roasts, and temperature, humidity and storage procedures can also effect this process.
On the other hand, waiting too long to use the coffee beans results in it going stale, from prolonged exposure to oxygen. Oxidation is the main cause of coffee "staleness". Grinding coffee speeds up degassing, but too quickly, and exposes it to more oxygen.
Timing is everything!
Source: Boot Camp Coffee
There is a lot of discrepancy as to when coffee is best brewed. Some say to wait until 2 days until after the roast for enough degassing to have occurred, while other say 3-5 days. Some say coffee is best within 4-10 days, others believe coffee to be at its peak in flavour at 14-15 days, but are still flavourful at 4 weeks, up to 6 weeks if properly stored. In the end, it all comes down to preference and the roasters experience with the particular type of coffee roasted.
Proper storage matters
To prolong the freshness of your coffee, keep the bean whole (not ground) and stored in air-tight containers - if it has a one-way valve even better, these allow CO2 to escape, while preventing O2 from coming in. Grinding coffee per use is the best way to keep the beans from oxidizing too quickly.
Avoid storing coffee in the fridge or freezer. As coffee bean are very porous, they easily absorbs moisture in the air, along with any odors present, negatively affecting taste.