As others have mentioned, this is referred to as Social Security. I'm not sure how it works in Canada once it's is forcibly deducted, but in the US, it's just a tax like any other tax. The idea is that the government will honor the promises made about the schedule of payments based on a complex formula - but basically it goes by the year you were born and the amount of money you have made over time. People who make less get a larger % of their earnings back from Social Security. The higher earners make more, but there is a cap. Similar to income taxes, there are steps in which you get back varying %'s, which is why those with lower income get more as a portion of their earnings.
In this way, the government simply collects money from current earners and then distributes that to the existing retirees. It's not like there is a trust set up and your money is locked away with your name on it. Canada's system may or may not be structured the same way. The idea is that if the government defaults on this, then there are much larger issues anyway. But because it's just a tax they can technically do whatever they want with the money and being the scumbags that they are, they periodically do steal from that money, which is why Social Security is underfunded.
Personally, I think the payouts are even pretty respectable, despite what others might think. The average payout is currently around $1,500 per person per month. That's not a lot, but if you have a spouse that's $36,000 a year. Also, one thing that most forget is that even if your spouse doesn't work their entire life (i.e. stay at home parent), a spouse can claim an additional 50% of their spouses as their own. Every person who is married has this option - they can claim their own or the 50% of their spouses (which does not reduce their spouses, it's just on top). For anyone working, it usually makes sense to claim their own unless there is a massive difference in pay. So if one person is scheduled for 2k a month, the other is guaranteed at least 1k or their own if it's higher.
Honestly, it's a nice idea and has been working reasonably well for decades. But the issue is that when you look at it with a technical eye, you'll see it's all basically the same structure as a ponzi scheme. The current people taxed don't pay for themselves, they pay for others who came before them. Over time the number of people required to pay for a single retiree has gone up. This indicates a growth requirement in the tax base. Without this constant growth which seems to go up more and more over time, the system fails. People ignore this because they think it's impossible because it's run by government. I'm not so sure that's true.