There are two mutually exclusive reasons for this and these two reasons divide all of beer into two camps - pasteurized and unpasteurized.
When Anheuser Busch started pasteurizing beer in the late Nineteenth Century it was a revolution. Previously, beer had an incredibly short shelf life. Most breweries could transport their beer only a few miles away before it would spoil. With his pasteurized beer and refrigerated railcars, Adolphus Busch could ship his beer nearly nationwide.
Soon, it was the norm for brewers to pasteurize their beer. Ironically, it was another of Busch's contributions that made pasteurization less necessary. Refrigerated railcars meant that beer could go farther even without being pasteurized.
I can hear your next question: Why not pasteurize anyway if it leads to a more stable product? Well, it is not that simple. Pasteurization stabilizes beer because it kills microorganisms. Bacteria is beer's enemy so this works out pretty well. Unfortunately, the process also kills yeast, the living soul of beer. In a sense, you could say that pasteurization kills beer. The beer is still drinkable and tastes about the same but it is dead. So, in the case of pasteurized beer, it needs to be consumed within a few weeks of brewing else the flavor begins to get stale.
Unpasteurized beer still contains yeast suspended in the beer itself. It is an important part of the flavor profile of many styles and vital, in some drinkers minds, to an enjoyable pint. There remains a small chance of bacterial infection but with the sanitary brewing methods that most brewers use today the chances are pretty low.
Beer with living yeast will continue to age and change in the sealed container. In most styles the changes are subtle but most drinkers can pick up on them if they pay attention. The changes are also quick and within the course of a few months the beer has petered out and that stale, lifeless quality starts to creep in.
So, I began answering this question with a discussion of beer's shelf life. Now let's talk about that shelf. Beer has three main enemies: heat, light and infection. The infection we discussed above and is really out of your control.
Heat and light, however, you can control. Besides encouraging bacterial group, heat can also simply damage the flavor of the beer. Brewers actually use heat by manipulating temperatures during the brewing process to come up with the precise flavors of their beer. So, it stands to reason that a few hours in a hot, parked car can seriously mess up that balance.
Beer's other enemy, light, is what leads to skunking. Beer can be skunked, or light struck, in a fairly short amount of time. Brown bottle, the best glass to protect beer, will still skunk a beer in just a day or two of sun-light. Green and clear bottles only need a few minutes to spoil beer.
So, the simple answer is, beer should be stored for a short time in a dark, cool place. If you have room in your fridge, that's the best spot. If you just made a beer run and bought far more than you meant to, then keep the beer in your basement or a centrally located closet. That baker's rack in your sunny kitchen where a handsome six pack would look so inviting is the worst place in the house for your beer.