That's the problem in a nutshell.
Unless we are prepared to live in a society in which people are allowed to starve there will always be those prepared to opt out of paying in because they know they'll be able to take out when the time comes. We need to find a way to rebalance things so that not working doesn't allow people to opt out of tax contributions yet benefit from the NHS, education, roads, defence etc that others pay for, and that includes pensions. Workers already contribute their time and energy to make goods or provide services and are taxed for doing so, when those who don't work qualify for means-tested benefits, pensions etc, and it's not fair by any metrics.
Anyone who is genuinely unable to work (eg ill, disabled, looking after someone who is ill or disabled, elderly after a lifetime of working) should of course be supported by those who are able to work, but we need to decide whether we want to continue to support those who are able to work and pay in but don't.