Praise be to Allah.
Are pensions halal?
Participating in pension plans other than those organized by the government is a kind of gambling, because a person may contribute to the scheme for a number of months, then become disabled or die, so he and his heirs may get much more money than was taken from them, or he may pay many installments then what he takes from them is less than what he paid. This is gambling . For more details, please see this answer: 8889 .
Investing pension money
If they are investing the money deducted in haram things such as making alcohol, or in riba-based loans, this is another reason to regard this as haram, because that is helping them in sin and transgression.
This applies if your participation in this scheme is voluntary. It is not permissible to participate in it in this case, and whoever gives up something for the sake of Allah, Allah will compensate him with something better than that.
But if participation is compulsory, then there is no sin on you, but it is not permissible for you or your heirs to take more than what was taken from you. You can leave the rest, or take it and donate it to charitable causes.
Participating in government pension plan
With regard to participating in the government pension plan , this may not come under the same ruling, in the sense that the government or treasury (bayt al-mal) is responsible for spending on the people if they need that.
And Allah knows best.