Your overall point about funding is correct, but typically the very best students and researchers don't have trouble finding funding. Thus the problem is how to attract the very best students away from Wall Street and cat picture startups, and stories like Instagram don't help with that.
The simpler explanation is that any programmer -- COBOL for bankers, CRUD apps, even "maintainer of Office installations for the IT department" -- commands a salary larger than that of a decently-paid Ivy League postdoctoral researcher. With minimal effort at steering one's career, the multiplier is two; according to rumors coming from the general direction of (e.g.) Google, if you've got talent and experience the number is a multiple of three.
You don't have to win the lottery. You start winning on the day of your first paycheck and you never lose, relative to research, because programming is a safer career than research.
Be careful about cherry-picking Wall Street and Instagram when choosing examples: Those are just the sensational ones. If Wall Street disappeared tomorrow, and venture funding with it, plumbers would still make more money than the average researcher. (Remember: A lot of research work is done by grad students, whose salaries make postdocs look pampered.)
"The very best students and researchers don't have trouble finding funding" - this is like saying "talented farmers have no trouble growing food". First, you're selecting a group of winners and then looking for evidence of winning. Lo, you found some! The second problem is that this statement doesn't account for effort: Farmers work hard and take risks for the money, and researchers do as well. As a researcher who wants to succeed you must have grants in the front of your mind one third of the time, and in the back your your mind most of the rest of the time, because success is measured in grants: Your pay, promotion, rate of progress, and reputation are directly contingent on the amount of grant money you can raise. Unless you're Einstein, maybe, but see above under "winning the lottery".
Face it, society doesn't value research as highly as going concerns. When you think about it, why should that surprise anyone? Businesses are a sure thing by comparison. You turn the crank, profits fall out. Often, happiness and human health fall out, too. Nursing, for example, saves lives. It saves them one at a time, but they get saved, and it's a sure thing: You don't need to make a bet against long odds. Change a bedpan, make someone considerably happier; notice that the patient has stopped breathing, save a life. Turn the crank. Turn the wheel the world has given you.