From Big Pharma's perspective, with the involuntary testing of prison inmates off the table in most Western countries, the homeless population presents a viable alternative who are statistically unlikely to pursue litigation.
From a humanitarian perspective, the quandary is "Do we want to allow the weakest among us to make decisions they are unqualified to properly weigh?"
I will leave the ethics to others, but ultimately, as future consumers of these tested pharmaceuticals, do we want to rely on results that are likely skewed because the test subjects were also taking heroin, methamphetamine, and cocaine?
It's not the companies sponsoring the test that somehow try to pick this demographic. It's the people themselves. Most of the tests pay the panelists, but it's not all that much. For someone with a stable job, the small amount usually isn't worth the hassle (have to be at the test location during business hours several times a week sometimes, keeping logs, or whatever). Not to mention not worth the possible health risks. For homeless/unemployed/etc., that's their electric bill for this month. It's enough money to them that they routinely lie about health conditions, drug use, etc. on the consent forms.
Only way to fix it is to offer substantially more money to panelists.
(Source: girlfriend who works as a clinical test manager)