there was lots of R&D in viagra. first off, it stared as medication for heart disease and when they discovered the other effects in trail (which already costs tons in man hours and supplies) they decided to use if for something else but it still needed to be optimized and perfected for that purpose... and then of course be ran through more clinical trials.
Reagents an lab equipment are very, very expensive. As a scientist myself I can tell you that even very small experiments that don't even result in anything useful cost 10s of thousands of dollars when you include these costs plus paying personnel and animal housing costs.
Also, as one that has worked on cancer, it is a misconception that money alone can cure something. Simply throwing money at cancer doesn't mean it will be cured any faster, the money has to be spent correctly and go to those researchers that have a good chance of success. Much of the grant money sent out by the NIH goes to labs doing research that will never cure cancer. In industry the motivation is profit so the funds go only to the projects that have the highest probability of actually working, it is focused, where as the NIH uses a shot gun effect. Personally, I think we need both, a healthy NIH budget and drug companies that research based on profit. They each have a role and we are weaker with the loss of either one.