Having a shitty attitude for that much of your life is no way to live.
That is literally the only way to live. Disaster stalks us an is only ever one misstep away (sometimes literally). In rare instances people can even just fall over and die.
In the sense that there should be food and shelter for everyone, even poor people; strictly speaking I think most countries have already agreed to that. Although how well that gets implemented is open to a lot of debate. But beyond that everything can always change at a moments notice.
I still tried doing a good job every day, and feel very good about that.
To me, being realistic about the risk of losing my job at any time means having enough money that I can be unemployed for 6-12 months.
The major way good programmers get jobs is by being recommended by people they've worked with at previous companies. That doesn't happen if you deliberately do as little good work as you can get away with.
My "shitty attitude" comment is maybe more a personal philosophy that something universal. But I do not want to spend each work day being bitter and resentful. You may intend to punish your shitty employer, but I think you're mostly poisoning your own mind.
And with less dedication, I can spend far less than half my time there ;)