I'd disagree with that. Some of the most entertaining bits of work I've ever done were for companies whose main job wasn't software.
The problem isn't companies who aren't focussed on software. The problem is companies that don't value the great things that software-oriented folk can produce. Unfortunately there are plenty of the latter in the software-focused end of the spectrum too.
Don't work anywhere that treats you badly. Sure. Don't work anywhere that doesn't value you. Sure. Don't work anywhere you don't enjoy yourself. Sure.
But I know some folk who are having excellent fun at banks. Solving stupidly hard problems that fascinate 'em, fostered by great management, and being compensated very well for their trouble.. I know others who have worked at large tech focussed companies that have had bloody awful stories of management idiocy. Hell — I've got more than enough horror stories from smaller tech-focused organisations.
Plenty of non-software companies can live or die on the quality of their algorithms. It could be a small development team but it can be challenging and rewarding. Plus it will give you a bigger perspective.
The key is to work somewhere that you are valued.
Notwithstanding the fact that a ton of companies that would like to believe they're "software" companies really aren't, the high turnover at Silicon Valley firms suggests that working for these types of software-centric employers isn't the happiness panacea you make it out to be.
Working for a "pure" software company is great advice if you are optimizing for overall happiness, but not so much for maximizing your income.
I cannot agree enough with this. I know it's anecdotal, but I've had more than ten jobs in my career so far and the only exception to what you're saying was an initiative by a highly technical and visionary director (later VP), which was scrapped as soon as he left the company.
The point I'm trying to make is that it sure is possible to have a really fun and challenging job as a programmer in a non-software company, but it's a stroke of luck you should never, ever rely on and it won't last. At least, that's according to my experience so far.
At any rate that was advice given to me by my father, who worked in the IT department of a large oil company, had a long line of pointy haired bosses who took the credit for anything that went well, which was eventually gutted and outsourced leaving just him and a couple others as insurance. I've regretted it when I did not heed that advice.