I've been thinking about this topic when I've read the news lately.
Developed countries are getting slowly safer and better, while some 3rd world countries show no progress at all.
I think the solution to this situation in the future may be highly developed artificial intelligence.
Most of the jobs will be done by robots (cars won't need drivers - you get an idea). AI will help us discover cheap energy, effective water filtering and so on. People will be receiving basic universal income.
But it is only my opinion and the development of such advanced artificial intelligence will probably take tens and tens of years (if not more).