Legal immigrants such as Ukranian refugees (religious refugees) can get SSI- Supplemental Security income if they meet the age 65 or disability and the income/resource criteria. They can also get public housing and food stamps and Medicaid- all paid out of general revenues. But to get Social Security that comes out of the Social Security Trust Fund, a person must have worked legally and paid SS taxes long enough to qualify (or had a spouse or parent that paid in sufficiently)
Over the years, many illegal immigrants have actually boosted the Social Security trust funds by working under fraudulent Social Security numbers where payroll taxes were taken out of their pay, but they never apply for or claim any Social Security benefits.
When their employer checks out that number and finds out from the govt that the number is someone else's and not legitimate, these workers are let go and have to find work elsewhere. The SS Administration runs number checks and if a number belongs to either a child or deceased individual (or someone elderly or disabled drawing Supplemental Security Income and the posted earnings mess up their income eligibility) Social Security Admin notifies the employers- but SS keeps those SS payroll taxes. The posted earnings are removed from that SS number so nobody gets the credit. So millions have been paid into the SS trust funds from illegal workers who never claim any benefits.