In 1881 Otto von Bismarck, the conservative minister president of Prussia, presented a radical idea to the Reichstag: government-run financial support for older members of society. In other words, retirement. The idea was radical because back then, people simply did not retire. If you were alive, you worked—probably on a farm—or, if you were wealthier, managed a farm or larger estate.
But von Bismarck was under pressure, from socialist opponents, to do better by the people in his country, and so he argued to the Reichstag that "those who are disabled from work by age and invalidity have a well-grounded claim to care from the state.” It would take eight years, but by the end of the decade, the German government would create a retirement system, which provided for citizens over the age of 70—if they lived that long.
This was a big "if," at the time. That retirement age just about aligned with life expectancy in Germany then. Even with retirement, most people still worked until they died.
There were exceptions though. Military pensions had long been given to soldiers who had risked their lives (though those pensions didn't necessarily mean they could stop working altogether). In the United States, starting in the mid-1800s, certain municipal employees—firefighters, cops, teachers, mostly in big cities—started receiving public pensions, too, and in 1875, the American Express Company started offering private pensions. By the 1920s, a variety of American industries, from railroads to oil to banking, were promising their workers some sort of support for their later years.
Most of these pension programs pegged the retirement age to 65. This mark had less to do with health and more with economics—workers could keep on trucking for years, and "old age" didn't necessarily mean bad health. (There was some research, however, that documented a decline in mental capabilities starting around age 60. Conventional wisdom held, too, that by 60 a man had certainly done his best work and should give way to the next generation.) When the federal government started creating what would become social security, some of the policies suggested would have had workers off the clock at 60, or even earlier. The economics of that didn't quite work, though, and so when the Social Security Act was passed in 1935, the official retirement age was 65. Life expectancy for American men was around 58 at the time.
Almost immediately after that, though, that balance changed. The Depression ended, and wealth and better medicine meant that in the post-war boom, Americans started to live longer. By 1960, life expectancy in America was almost 70 years. All of a sudden more people were living past the age where they had permission to stop working and the money to do it. Finally, they began to retire in large numbers—to stop working, to embrace leisure, to golf. For a few decades, older Americans lived without working, enough that we've come to expect that we should be able to retire, even if that may no longer be financially possible for many. Today, the Social Security Administration estimates that there are 38 million retired people in the United States alone.