I would suggest teaching programming to those who may never have the chance to learn. It would benefit society and your own spirit. There's plenty of ways to go about this and many of them can provide a nice living.
Above all, I would suggest that you find one thing (outside of work) that makes you happy/fulfilled and jump headfirst into it. Community service, outdoor sports, painting, drums... whatever. You'll be less frustrated and more pleasant to be around at work and at home.
Markets and capitalism are supposed to fix this fundamental problem (archaic, stupid leadership) by reallocating resources where they can be best put to use, by this isn't a problem that mere computation (as in a market) can solve. The problem is that power is held by the wrong fucking people, most of whom are total imbeciles with no vision, and the runaway feedback loop where power and wealth beget same is too far gone for talent to break in and change things.
US-style corporate capitalism is an outright disaster but, while EU-style socialism makes life suck a lot less for average people, it doesn't solve the underlying problem either.
Eventually, the discrepancy between what's possible with technical creativity and what's being actually done out there will reach a critical point and, like an insulator breakdown, sudden and powerful change will happen. I have absolutely no idea when that will happen, though. We have to purge and recreate the whole industrial ecosystem in order to get to the kind of world that people like you and me want-- a world driven by creativity and challenging problems rather than subordination and nonsense.
> I enjoy the freedom and art and creativeness, but when things don't work, which happens a lot, I waste time on it and feel stupid and depressed. Feeling smart 1% of the time and stupid 99% of the time
Yeah guess what, that same thing gets at me ever since I started programming. I still like doing it, but that aspect is truly increasingly an issue in the activity since late 20s / early 30s now. How enjoyable you spend big chunks of your lifetime does matter after all, and you increasingly get that horrible nagging "time's flying faster every day now, I'm running out of a fixed resource one compiler error at a day" feeling..
(1) Knowing what's possible or will be possible with cutting-edge technology
(2) Understanding the pulse of the market
Each skill is already rare, but having both is an incredible combination.
As a developer that is much closer to 50 than many here are, I can say that it's a crapshoot whether I will be programming when I'm 50. I tired of it after a handful of years, but decided to stay on with it because I can't afford the paycut, and am still am going with it, getting close to 15 years now. But everyday, and I've tried another employer, I still can't stand it. I enjoy the freedom and art and creativeness, but when things don't work, which happens a lot, I waste time on it and feel stupid and depressed. Feeling smart 1% of the time and stupid 99% of the time and worrying about whether you will be able to continue it without getting fired is a horrible way to live. It has affected my health, my attitude, and makes me drink more than I should at times. But, we justify this with "we are making a good living".
Common things I think about doing are (1) buying and running a bar, but then I would have to deal with the alcoholics, prostitution, drugs, and other crap that goes with it (not worth it) and would feel that I was contributing to an evil in our society even though I love beer and good times, (2) selling old computer equipment and games (there is little money here, and I'm not a hardware expert, so screw that), (3) getting involved with my church (but they don't need more IT, I'm a developer anyway not IT, and I have no idea what else I have to offer), (4) helping humanity get into space (but I have little to offer there also), (5) developing Indie games (which I've done in the past to some extent, but I think that writing games just means that people will waste time away from their family and solving problems playing them), (6) going to work for a non-profit development group (but I'm a conservative, and I can't work with tree-huggers even if I have a very liberal opinion that software should be free or open source, which I realize is not the same). So instead, I take care of my family.