Beer never becomes unsafe to drink, so retailers are under no legal obligation to sell fresh beer. Most people don't think much about beer freshness, so retailers who sell stale beer aren't punished by consumers. However, the age of a beer is vital to its flavor. I don't doubt that some people like the flavors that age and oxidation impart to beer, but I think that most people, like me, dislike these flavors.
Large American lager breweries have spent a great deal of money developing extremely low-oxygen brewhouses and packaging lines to allow their pale, weak beer to last six months in refrigerated storage. Retailers generally understand this shelf life and are able to move these beers on schedule. Craft beers are the problem. Craft brewers produce a huge variety of different beer styles, each of which ages differently. American IPAs are the poster child for beer freshness, since the vast majority of American IPAs are sold extremely stale. Furthermore, craft breweries are often unable to afford refrigerator space in stores, which only worsens the problem.
As my small contribution to fixing the beer freshness problem, here's my impression of the aging potential of various craft beer styles (assuming refrigerated or cellared storage):
American IPA - The most fragile of beer styles. Nearly all of the fresh hop aroma that the brewer has worked so hard to get in the beer will be gone in 1-2 months. The flavors that replace it include molasses, cardboard, and cat piss—none of which I like in beer. Do not age more than six weeks in the bottle/keg.
American/English pale ales - The fresh hop aromas in most American pale ales will fade just as quickly as in IPAs, but pale ales are generally less offensive to drink aged. Nevertheless, don't age them more than three months.
American/English dark ales - Roasted malts are powerful antioxidants. High alcohol stouts are the only beers I brew that actually benefit from extensive aging. Stouts get softer and more complex for at least the first year, and will be delicious for years after, since the roasted malts stave off oxidation. Lower alcohol dark beers don't need as much aging, but will still hold up to a year or two of storage without much trouble.
Belgian pale ales - Tripels, golden strong ales, and saisons have a better shelf life than American pale beers, since they're less reliant on hop aroma, and I think Belgian yeasts have some antioxidant capacity. (Need to confirm.) I'll happily drink a tripel at six months, maybe even a year. I don't recommend longer aging, though some do it anyway. For Belgian pale ales with Brettanomyces, see sour/wild beers.
Belgian dark ales - Dubbels, dark strong ales, and quadruples already have a lot of dark sugar/dark fruit flavors, so oxidative flavors are less obvious. They're not one of my favored styles, so I don't feel qualified to say how long they can be aged, but many people do age them extensively.
German wheat beers - Hefeweizens are known for their banana aroma. The ester associated with this aroma, isoamyl acetate, fades fairly quickly in beer. Less than three months is best with weizens.
Sour/wild beers - Most sour/wild beers take at least a year of fermentation before they're released, so freshness is clearly not paramount here. (Lambics are brewed with aged hops!) But if the beer is pasteurized (as most Flemish sours are), it's best drunk fairly fresh. If unpasteurized, sour/wild beers continue to evolve in the bottle, often becoming more sour and complex. However, aging a live sour/wild beer can also throw off the balance of flavors, and in the case of fruit beers, diminish fresh fruit aromas.
A note on barleywines: One style of beer embraces the flavors of oxidation, just as sherry does in the wine world. That beer is the barleywine. Barleywines don't have roasted malts or wild yeast to protect against oxidation. Nevertheless, they're often aged for many years. Aging does soften the alcohol bite, but it also brings the typical nutty, brown sugar flavors of oxidation. Many people enjoy this in a barleywine. I do not. I don't brew barleywines.
Can't find the date on a beer? For a guide to best by dates and bottling codes, visit http://freshbeeronly.com