What is not risk-free is the value of those bonds before reaching maturity. That price is decided by the market (i.e. you need to find someone to buy them from you, therefore there is a price to be negotiated). Why? Because when the government issues new bonds at higher interest rates why would anyone still buy the old bonds at the same price? If you want to sell those bonds on the market you will have to sell them at a discount. OR you can hold them to maturity and get paid in full.
What went from here is that those pension funds used those bonds as collateral (the value of which is decided by the market). Since the market value of those bonds is falling now due to rising rates, the value of the collateral is decreasing thus margin calls.
Everyone knows this and no one seriously thought this was risk free. The simple fact is that all these pension schemes are underfunded yet there is the expectation that they still pay out pensions like they did 50 years ago. How to solve this? You take on risk!
Im not saying that the bankers are all nice guys here but it’s not solely their fault. There is some context here. People just prefer to sweep away problems until there is no more place to hide them. That’s the real issue here.