I'm surprised that this is your framing, I don't think I would hesitate to offer a willing tenant or otherwise good employee a job because of their legal status. Mostly just on principle, it's not my job to be an arm of the state and I resent being deputized. They're physically here in my town, better they have somewhere to live and a means of supporting themselves rather than being homeless. If the state wants to find and deport them they can do it themselves on their own time.
In the UK, by law employers must check that the people they hire have a legal "right to work", i.e. are citizens or foreigners with the relevant visa. In England, landlords must check that prospective tenants have a legal "right to rent", i.e. are lawful residents. Penalties are hefty fines and up to jail.
Hence "flunking the law".