I think a mediocre/bad job is tolerable when you have other things going on in your life (good social life, good family life, financially stable, whatever).
I used to have a comfy tech job, however over a certain period of time I grew to hate the job because I realized in the grand scheme of things I'm disposable and how unimportant the job is. It was also boring and I had nothing going on in my personal life, nothing to look forward to when I got home. So over time at work I felt less motivated, more isolated, just pointless boring/mundane really.
That was the fundamental difference when I was a small kid, even though I disliked school I looked forward to hanging out with my friends after school which made school way more tolerable. It made doing things I dislike doing more tolerable. But as long as there is some reward you can look forward to sincerely enjoy, it makes all the negative parts of your life much more tolerable. It's when you have fewer and fewer good things in your life, when your life is focused more and more on simple survival, the suicidal thoughts and existential questions come up like "why the fuck am I even doing this? What's the point? This is leading nowhere."