The advanced mechas said the human race was extinguished. How did that happen? Because the Earth froze? Weren't there any humans living in space stations or moon colonies?
Global warming followed by a catastrophic ice age.
The initial voice-over describes a world in which runaway global warming has already resulted in the deaths of hundreds of millions of people and a dramatic loss of coastal land. Those that remained were only able to survive (and indeed to thrive) because of drastic population control and the presence of a new 'slave class' of artificial people.
Those were the years after the ice caps had melted because of the greenhouse gases, and the oceans had risen to drown so many cities along all the shorelines of the world. Amsterdam, Venice, New York, forever lost. Millions of people were displaced, climate became chaotic. Hundreds of millions of people starved in poorer countries. Elsewhere a high degree of prosperity survived when most governments in the developed world introduced legal sanctions to strictly license pregnancies. Which is why robots, who were never hungry and did not consume resources beyond that of their first manufacture, were so essential an economic link in the chain mail of society.”
In the final scenes we see the ultimate result of the loss of the ice caps; extreme melting (and the flooding of the cities) followed by a new ice age, freezing the melted water and encapsulating the cities in ice.
When Aldiss described Kubrick's vision of the film's ending, he noted that there were three key elements that he was keen to preserve at all costs;
...Global warming, the eventual triumph of the robots and the Blue Fairy.
According to Brian Aldiss, the directors plan for A.J. emphasized the planetary alterations and eventual extinctions that global warming would gradually cause. The catastrophe would not be a sudden incineration but a steady progress from the chaotic conditions of a hotter planet to a life-destroying ice age.