As beans age, you face a scenario similar to the law of diminishing return. Chemically, lots of stuff happens to coffee as it get older. The result in the cup is a drop in acidity, decline of clarity, decline of varietal/origin character, decline of body, thin mouth-feel, decrease of aromatics...and a host of many other negatives.
How long a roasted coffee is fresh depends on many things, like packaging, density, roast degree, process type, form (pre-ground/whole), relative humidity, exposure to light, temperature exposure...etc. As a rule of thumb, a coffee about 2 weeks off roast is at its peak in quality, give or take. Lighter roasted high elevation coffees (high density) such as our Kenya Nyeri Karatina Peaberry and Guatemala San Rafael Urias tend to age very well. Low grown coffees (low density) such a many Brazilian or Hawaian Kona coffees tend to age very quickly. [Soap Box]: Hawaiian coffees are some of the most expensive coffees to buy in the United States. A fresh Kona is a delightful experience, but most people buy a bag from a grocery store that was roasted 4-5 months before they brew it. Any goodness from these coffees are long gone. Unless you buy a bag from a roaster that is clearly marked with a roasted on date, don't waste your money on Hawaiian coffees. [Off Soap Box]
When brewing coffee that is old, perhaps a month or two past roast, you might notice that a once fruity and floral Ethiopian Yirgacheffe now tastes rather generic. This didn't just happen all at once. If you brewed this coffee exactly the same each day over the span of 2 months you would notice that it gradually declines in quality, it doesn't one day go from being really good to blah. If you brew this coffee for espresso, for example, as the coffee ages it becomes thinner and decreases in body. To compensate for the age, one can slightly increase the dose (amount of coffee used) or grind a bit finer. Changing one or both of these factors can extend the "life" of this coffee for awhile, but at some point increasing dose or grinding finer can no longer compensate in cup quality. This is what I call the "Law of Diminishing Return" when applied to coffee.
Interestingly, coffee that is newly roasted needs a couple days of "rest" before brewing before many of the flavors start to really show themselves in the cup. For espresso use, 3 days of rest is the minimum we recommend before brewing, 5-6 days of rest seems to be a sweet spot for most espresso coffees.
How a coffee ages after it reaches its peak can be a perplexing. Oxygen, light, high humidity, and high temperatures all seem to be enemies of freshness. We package our coffees in high barrier bags with tin-ties. Once open, we recommend folding the top down, expelling as much air as possible, then secure closed with the tin-tie. This will protect the coffee from excess oxygen exposure, light, and changes in humidity.
If you don't plan on using the coffee for a few days, it is okay to put it in the freezer. To do so successfully, place the tin-tie bag inside a Ziploc freezer bag, expel as much air as possible, then place in your freezer. The important part is to remove the bag several hours before use and allowing the coffee to return to room temperature before opening. If you open when frozen, moisture in the air will condense on the cold beans and get them wet (think a glass of iced tea and the water that forms on the sides of the glass).
So How long does roasted coffee stay fresh? The simple answer is: It depends. But, a good rule of thumb is a coffee retains most of its "fresh" attributes until about a month after it was roasted.