All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
The social insurance, whether health or otherwise, which is run by the government as a means of benefiting its citizens and helping them in case of accidents and diseases, should be looked at according to its purpose. If the purpose of the government is purely cooperative and it has no aim to make profit, and the participants in it are paying their money or instalments as a contribution, then this kind of insurance is permissible. It is included in the cooperative insurance which the Fiqh Committees ruled that it is permissible under some conditions among which are:
1- This money should not be invested in forbidden fields.
2- The insurance should abide in its laws and regulations by the rulings of Islamic Law.
However, there is a problem with the situation which you asked about in your question, which is the source of financing this insurance and the fact that it is obligatory.
The source of financing this insurance is an imposed tax on every individual who is usually subject to tax, in addition to the subscription which the rich people pay, and who wish to benefit from it. There should be no correlation between what they (the rich people) pay and what they take, otherwise this insurance is not cooperative but commercial and forbidden.
Furthermore, you do not know the intention of the people who contributed in this kind of insurance, and thus you should not concern yourself with it. Rather, what you are concerned about is the issue of imposed tax. The tax is of two kinds: permissible and forbidden, and this is clarified in Fatwa 89947.
So, if the tax is forbidden, it is forbidden to work or subscribe to this kind of tax because the source of its financing, or most of it, is forbidden money taken from people illegally. Nonetheless, if the tax is permissible, then it is permissible to work or subscribe to this kind of project.
Allaah Knows best.