Large populations of young people used to be these countries’ greatest strengths. But in the age of AI, that group will be made up of displaced workers unable to find economically productive work. This sea change will transform them from an engine of growth to a liability on the public ledger—and a potentially explosive one if their governments prove unable to meet their demands for a better life.