In our society we have chosen a different solution, pretty much all over the world: your ability to have food and shelter is conditioned on having a job (or being born rich), but in exchange, the state tries its best to guarantee you a job. We don't generally allow the state to operate companies, so the only way for the state to guarantee jobs is to incentivize and even force companies to employ people without discrimination, to at least some extent.
Now, my personal belief is that the justification should come the other way around - why do we allow society to judge your right to a basic livelihood by any criteria at all? But I'm guessing that would not be a compelling argument, and I can't claim to have a working picture of how such a society could look like.