I like the idea that businesses can specifically hire homeless people who need it, but what I'm not quite sure of is how businesses are able to do that on an arbitrary basis, because as far as I know they are supposed to make the position publicly available and conduct interviews for any applicants.
You don't specify a jurisdiction, so this answer will be as general as possible, but specify jurisdictions for examples.
You are under two misconceptions:
1) The arbitrary selection (hereafter referred to as "discrimination") is illegal in general.
2) A position is required to be publicly announced
As a general rule, discrimination is legal, acceptable, and in some cases required; however, many places forbid discrimination on specific attributes. For example, US law forbids discrimination on sex, race, religion, and national origin, among other things, barring a specific demonstrable need; all forms of discrimination that are not forbidden by law are allowable.
For example, my department has the following legal discriminatory biases: a bias against those who lack university degrees, a bias in favor of a specific local university (which about half my department graduated from), and a bias for our own membership (e.g. promoting from within).
Open job postings
As a general rule, a company is not required to publicly announce positions. Governments are often required to, sometimes by their own rules, but this is to protect against corruption and cronyism, rather than an absolute. For example, there is not a public posting for, say, US Supreme Court Justices or Cabinet Secretaries.
Larger corporations, especially publicly traded ones, often adopt similar rules, to protect the company and shareholders from internal corruption (e.g. a manager hiring a friend to a position that they are not qualified for, or receiving a kickback bribe for their hiring decision), but they are not required to unless a specific law or program they are enrolled into requires them to do so. For example, some Federal Contractors are required to post their positions publicly, as a condition of their contracts.
So, in summary, there is no reason why a business cannot arbitrarily hire a homeless person specifically for being homeless, unless a) homelessness becomes a legally protected category, or b) a specific rule or government contract provision requires public posting of open positions.
A/N: Just go read sharur's answer, really, it's much more thorough and general than this one.
Only certain demographics are protected classes for the purposes of anti-discrimination, in American jurisprudence. Neither "Poor people" nor "rich people" nor "middle-class people" are protected classes. Thus, you can discriminate in your hiring process on income. Race, on the other hand, is a protected class. Therefore, you can't discriminate based on race in your hiring processes.
In short: Only certain aspects are protected, and as long as you don't discriminate on those aspects, you're fine.