FDA requires testing. testing expensive... really ... how hard would it be to grab 50 tablets per drug for each environment (high UV, extreme humidity etc..) let them sit and once a year grab a pill and run chem analysis. Sounds like it could pretty much be automated, except for maybe the maintenance of the environments. Maybe 500k to 1m per year with the work out sourced with various statistical validations. (Yes I realize this is hard part, damn humans) Take all the generic tablets and voila..
Drugs are cheap to produce
Really though, medicine doesn't cost much. It costs because society deemed it so. As it's been explained above/below, but, paying for research, marketing and regulations is probably 90% of the cost.
The hard question is
A more interesting question is how much can we afford to help others when they are sick? If the difference between health is as trivial as getting the right medicine I know I'd feel guilty if I didn't do something. This is especially true for chronic disease, as the cost benefit is tilted.