In most instances, the choice to have kids or not have kids are both driven out a selfish desire to get out of life what one wants (though of course married couples may have one person's desires more filled than the other's). My friends had kids because they wanted to have the experience, have dependable relationships as they age, have someone to ensure they're cared for in old age, etc. It's not out of some altruistic behavior to ensure social security is stable for another few years.
That the decision benefits our societal structures (though likely harms the environment and natural ecosystems) is a side-effect.
It can be as simple as having younger people to spend holidays with, or maybe take you to the doctor once in a while, or give a helping hand for a home improvement project.
That said, the correlation within developed countries between income and how many kids you have varies IIRC, some places richer people have more kids, in other places they have fewer.
Obviously these are not true needs, but if people feel like they're needs, they can still become factors in how many kids you have.
But they really can’t due to economic circumstances. Unfortunately that’s something some people don’t want to acknowledge, often for political reasons.
I don't think this can be the entire situation. Anecdotally, both my wife and I have grandparents who lived for extended periods of time with three kids in mini camper trailers because they couldn't get into any other housing. They really wanted children, and it was a high enough value for them that they sacrificed a lot to have them.
Additionally, economic prosperity and higher living standards are typically correlated with lower birth rates. People who technically can most afford children, are less likely to have them. This is the opposite of what I would expect if finances are what prevent people from having children.
Having children now, I cannot fathom living in a camper trailer with them, and I am not saying that people should be doing that. My point is that different people (across different economic situations and different time-periods) have varying priority levels around having children. And that is ultimately what determines how many children are born.
The average person in their 50s or 60s financially better off than the average person in their 20s or 30s. The average young person can reasonably expect to be wealthier 30 years from now. Therefore many young people feel poor, and they feel they need to be in a better financial position before they can seriously consider having a family.
I think the rise of the middle class had a huge impact on birth rates. Ordinary people were no longer living from paycheck to paycheck. Instead, they were capable of building wealth over time. That made young people poor, both relative to the average person and relative to their expectations. And many started seeing family a luxury they could not afford yet.
Nothing economically prevents anyone from having children other than being unable to afford the food to grow one. But as one could imagine, very few people probably want children, if it also meant that they'd be homeless. In other words, someone's want for a house can be greater than their want for a child. And this can go for anything (from spouse, to life circumstances). Again, it's not that most people can't economically, it's more that many people don't want to sacrifice other things that they also want.
My great grandparents had 8 kids, their kids had 4, mine 2, and me zero. There you go. Each generation in my family at least was financially better than the last.
I’ll go so far as to say many put sex ahead of kids, and when the sex dies so does the family. Kids be damned. Next level hedonism enabled by our advanced technology that we are unable to resist.