Directive 2004/38/EC ("Free Movement Directive") provides EU citizens who are entitled to free movement with the right to equal treatment (Article 24 (1)). But in accordance with Article 24 (2), member states are not obliged to confer entitlement to any tax-financed social benefits to persons other than workers, self-employed persons or persons who retain such status during the first three months of residence or during a longer job-searching period. This policy takes up the incremental residence rights from the Free Movement Directive (see legal framework).
Germany has introduced such exclusions from benefits in section 7 of Book II of the German Social Code and in section 23 of Book XII of the German Social Code. The Court of Justice of the European Union has confirmed this principle in various preliminary rulings providing a high level of clarification at the EU level on exceptions from the principle of equal treatment in the field of access to social benefits ("Dano vs. Jobcenter Leipzig" (C-333/13), "JC Neukölln vs. Alimanovic" (C-67/14), "Jobcenter Recklinghausen vs. Garcia" C-299/14) , "JobCenter Krefeld" (C-181/19).
You can find further information on the entry and residence of EU citizens here on the website of the Federal Ministry of the Interior.