Prior to the 1950s, most men dressed in a uniform fashion. Your appearance might vary depending on your class, but within social classes, one man looked pretty much the same as the next. A neatly trimmed haircut and a suit were standard everyday wear, and a hat to go with it.
After WWII, the 1950s saw the invention of the teenager. Youth culture was more prominent than ever before, thanks to many factors, both social and technological. As those teenagers entered the workforce, they were filled with new ideas about individuality and style. Along with the Baby Boomers ideas about style also came changing ideas about hats.
The change didn't come overnight, of course, but by the time JFK became president in 1961, you could see a definite trend away from hats and suits and every man's hair cut well above the collar. It would take another decade or more for hats to really fade out, more or less along with the decline of suits in general.
Take a look at this film from 1967, How to Succeed in Business Without Really Trying: http://www.youtube.com/watch?v=OJgaaAfhR5I
Watch for the crowd scenes in Manhattan at the beginning. You'll see a lot of hats, just not as many as you would have seen on the street ten years earlier, but far more than you'd see in a crowd scene from the same area in 1977.
There was no single cause for the decline in men's hats, and it didn't happen all at once. Stories like "it was Ike with the interstates" are appealing and make good cocktail party conversation (although I suppose the cocktail party died along with the hat, now that I think of it), but reality is usually not that discreet and simple.