In principle, all those who are allowed and able to work should make their own living by working. However, the state helps those who are not capable of doing so, or those who are only capable to a limited extent, for example if they cannot find work or are ill. In this way, the state helps those who are disadvantaged.
The strong protect the weak
The welfare state is based on solidarity. In order for it to work, everyone must pay taxes and social security contributions. This is why part of your salary is taxed. Your employer deducts a portion of your salary. This money is paid directly into your pension insurance, health insurance, unemployment insurance and long-term care insurance. You also pay tax on your wages ("Lohnsteuer") and other taxes. This money is paid into the national budget, which is used by the state to provide for the population.