Francois Furstenberg argues that the “welfare state” (I hate that term, btw) was initiated out of self-defense by the wealthy of the Gilded Age. The extreme economic disparities of the late 19th century was causing widespread violence and threatened to tear the country apart. And these were people with living memory of the Civil War, so tearing the country apart had a reality to them.
The Gilded Age plutocrats who first acceded to a social welfare system and state regulations did not do so from the goodness of their hearts. They did so because the alternatives seemed so much more terrifying.
I don’t think that’s all there was to it, but it’s an interesting thing to consider.