Can definitely speak to these cases - especially where you do great work and have a narrative that it was unappreciated - and clearly see lesser performing or less impressive colleagues getting ahead. For a lot of people, it takes only a few instances of this to switch to "I'll do the bare minimum not to get fired - why sacrifice much of my life and mental energy for this?"
I've been there a few times, and to speak to your point: I decided that instead of being a dead weight I should just look for another job where I don't feel this way. I can say that amongst my peers, that behavior is an exception. Most people who become deadweights will remain that way. It's work to find a new job, and you may have to move, etc. Amusingly enough, Leetcode style interviews are effective at ensuring deadweights remain so.