There is nothing wrong with the worker subscribing to a retirement scheme or state insurance fund, if doing so is compulsory as is the case in some countries, because the worker is excused for that and the money is taken from him without his choice. Hence many scholars regard it as permissible to make use of what comes from this scheme, and they regarded the extra amount from the state as coming under the heading of the state’s duty to take care of the weak and look after them.
But in the case of voluntary subscription, it is not permissible to subscribe to this fund, because it is based on gambling and uncertainty. The individual may take more than he paid or he may take less than that, and this is gambling. Moreover, the money is deposited in riba-based banks, as you stated, and it is well known that it is not permissible to deposit money in riba-based banks with the aim of getting the interest, because that is consuming riba and helping those who deal in riba.
And Allah knows best.