The rule of thumb is that you first drink coffee approximately 3 days after it is roasted, but what is the exact reason for this?
Fresh off the roast, coffee has high levels of carbon dioxide and nitrogen (based?) gasses. These gasses will greatly contribute to retro-nasal activity as well as initial flavors (think carbonated water). The most apparent flavor one gets from this is metallic. At my work, 4 days is considered minimum for serving and tasting, although there's always exceptions.
The flavor and aroma of the beans continue to develop for the first few days after roasting as the beans release gas (this is the reason some retail coffee bags have valves to let the gases out). The process is similar for bread, with some bakers preferring to let some types of bread rest longer than others.
Right now I am actually drinking a cup of coffee made from beans I roasted this morning, because of poor planning. There's nothing wrong with it but I think it will be better in a couple of days. I find the aromatic qualities peak about 24-48 hours after roasting, but that may be because the off-gassing process is literally emitting the most fumes.
How the flavor changes
Subjectively, I'd say the smell and taste change like this:
During early roasting, there are wood and vegetable smells, like when you put green wood on a fire and it puts out a lot of moisture-filled steam and begins to smoke.
Toward the end of the roast, the smell is more from the browning/caramelization/Maillard reaction and smells kind of like burnt toast. Not really much like coffee.
If you grind and drink it immediately after roasting, it tastes like generic coffee, with those toasty flavors foreground. Very simple and straightforward without a lot of nuance.
After 24 hours the toasted character has diminished and the nuances have developed a lot more. You can really notice the difference between bean origins. There is much more powerful rich "amazing coffee" aroma. I find the sheer quantity of aroma very appealing at 24-48 hours.
Some beans continue to change for several days after roasting. Recently I had a batch of Indonesian beans that were still developing and becoming more characteristically Indonesian after a week. I liked them more, but someone else might have liked them less.
And that, when it comes down to it, is what matters. Some people find some varieties more interesting, more palatable or less harsh as they age. But de gustibus non est disputandum.
It's amazing the human nose and tongue can sense these differences.
- "Degassing, resting, and storage" at thecoffeefaq.com, recommending at least 24 hours
- Sweet Maria's claims coffee is "at its flavor peak at 12-72 hours" and recommends a minimum 12-24 hour rest period.
- forums like home-barista.com report much variation on preferred resting time.
Ethiopian coffee ceremony cases from hundred years ago until now, they brew coffee just after the coffee bean cooled, they have no de-gassing time they solve this smoke like off-flavor problem with fine grinding and boiling once again after they pour coffee ground to the Jebena with hot water . Also, they roast coffee to Italian roast degree which has very small smoke remain. Degassing time can be shorten as the roast degree gets darker. My full-city cases it need at least 12 hours and maximun flavor at 3days From Korea, Jinsung Lee Ph.D.
Edit 02/26/2016. I am now convinced that resting the beans is necessary. There are just two many roasters I've heard from (on here and in person) that believe it is necessary, and I have seen with my own eyes changes in the appearance of the beans a day after the roast (they seem to darken a bit).
Previously (while still unconvinced). John Snow's and Nathan's answers sound very plausible, but I'm still not convinced that resting fresh-roasted coffee (past the point of cooling) improves its brewed taste. As far as I can tell, no one has ever proven this. DISCLAIMER - I don't want to believe it, because I think brewing after roasting is fun. But I will eventually listen to reason if strong enough arguments present themselves. Below are a couple of points that allow me to remain in disbelief.
There's a guy on YouTube claiming the resting fresh-roasted coffee principle is a myth due to a mistaken case of cause and effect from unskilled coffee shop employees. He goes so far as to tell his own myth of a teenage kid (suffering from acne - nice touch) who sees his employer resting the beans and makes the conclusion that they're better after they sit. But really, the employer is letting the coffee rest because it's impossible to brew large amounts of really fresh roasted (it will explode or something) and the teen is just too lazy to ask. He just wants to smoke weed.
Now if you're not convinced by the explanation above, the only scholarly source I could find is Michael Sivetz's Coffee Processing Technology, Volume 1, where on page 248 he writes,
Beans cannot be ground directly after roasting as they are too soft and would be crushed, flattened, and scarred. When the beans are cool, hard, and brittle, they may be ground.
So I just have to cool them down? Ok, I may be extrapolating a bit since this book is about getting coffee to the masses. And it's very old.
Finally, I'm not a scientist, but I just don't see how carbon dioxide escaping from a bean is going to change the flavor of brewed coffee, especially considering the bean is about to be pulverized and soaked in near boiling water.