Humanity has endured worse. And this is very short sighted view of humanity. How do you think we got here? To struggle to survive is at the essence of Trek but there is optimism that growth through challenges makes us better.
Viktor Frankl and "Man's Search For Meaning " discusses this at length.
Humanity has had apocalyptic literature for millenia now.
The world is better today than when such literature was first written. Hold fast to the good, and spread it to all you see. That is the power of endurance.
Humanity may have endured worse when people lived in trees and worshipped sticks. But back then they didn't know of a life so much better than that.
I think it would be totally devastating for humanity of today to be struck by a nuclear war and the aftermath of that. It would send the survivers back to the stone age and it would take millennia to recover from that. I don't think it would be beneficial in any way for humanity either because it would most likely result in a "humanity" totally without compassion and will to cooperate. It would be all about survive at any cost and of the expense of others.
I agree with your statement that humanity has had apocalyptic literature for millenia now.
However, there was a time in the 50's and 60's when people actually started to believe that the future would be better than what we had. Unfortunately those dreams seem to be gone now.
It affects the entertainment and literature as well. Back then there were stories about space exploration and development. The creation of Star Trek was a result of that.
Now every movie and new series about space exploration seems to be about some survivers running away from a devastated Earth to find some other planet to destroy. And the main charactersa are mostly unlikeable.
I actually try to hold fast with the good and spread it. But it's not so easy in a world where negativism is poured over me every day by media and those who believe in what media tells them.
Not to mention when I did find a few good books to read and expressed my liking for it, only to discover one day later that the continuation of that book series was nothing for me.

I don't think it would either. Frankly I don't think humanity will fundamentally change, whatever happens. Seeing how humans behave in the Star Trek Universe is a bigger leap of fantasy to me than the invention of warp. A nice daydream though, and something to strive for even though I don't think it will ever happen.
But the question I was attempting to answer was not what would realistically change humanity, but why they came up with the idea of nuclear war and the post-atomic horror in the mid-21st century in the first place as a background history to the Star Trek universe.
I might be naive but I do think that humanity can develope into something better. After all there have been some development in that direction. There were times when war was seen as something natural. Now we at least protest against it from time to time.
If humanity avoid blowing themselves to kingdom come in the upcoming centuries and manage to solve certain problems with over-population and lack of food and natural resources, there might be hope.
But as I wrote above, a nuclear war with its aftermath would send humanity back to the stone age, not only materially but mentally too.
As for Star Trek's solution for a background history, it was made in the 60's which was a very contradictional time.
There was a lot of positive views of the future and dreams about peace, love and understanding. But it was also the time of the Cold War with a possibility that everything could go very wrong. I guess that Gene Roddenberry used the "worst case scenario" as his background history for reasons I don't understand.