It used to be that immigrants would simply invent a fake SSN in order to get a job. The e-verify system may have complicated that, but I imagine it's still pretty much the same for smaller businesses. And especially agricultural work, meat processing plants, etc. All the businesses that rely on undocumented labor.
So the immigrants are paying into the SS/medicare system, but they don't receive any of the benefits.
I think the solution to the housing problem is to increase supply. Not to try to prevent a whole group of people from being able to buy homes.