The Great Depression (2030 - 2050) wiped out 2/3 of humanity, buried nation states and forced survivors to take concepts like democracy, sustainability and the environment really seriously.
The survivors faced the worst consequences of climate change, learned citizenship values and even rewrote the Universal Declaration of Human Rights stating that human beings have the right to peace, that proselytism is prohibited and that everyone has the right to an environment free of pollution.
The population did not recover easily. Even generations later the idea of having many children seems foreign to most, over the next two centuries the population grows slowly from 2.8 billion to still less than 5 billion.
However, it is a remarkably happy period for them: nuclear fusion is already a reality and the abundance of clean energy creates many opportunities. Different types of catalysts invented at about the same time at different research centers make water electrolysis efficient, with hydrogen-powered vehicles everywhere. Carbon allotropes allow for new constructions, lighter, more resistant, cheaper and even with the bonus of the raw material used being the 1.8 e+14 kg of carbon present in the excess carbon dioxide in the atmosphere.
In fact, the success of using graphene, nanotubes and carbyne to build everything was so great that the concern was reversed! It was feared that it would withdraw too much.
Laws (and taboo, perhaps stronger than any law) prevented mining or any other activity that might create a new imbalance in the Earth's carbon cycle (as well as the cycles of nitrogen, water, phosphorus, etc.).
So in 2070 they decided to go back into space.
Not for a competition of countries.
Nor based on the ego of billionaires.
Inhabit other planets? Earth seemed a lot more spacious now with half the population it once was.
The concern for sustainability extended to space: rockets launched from the surface were a thing of the past, from the heroic era of space exploration (1957 - 2030). The elders spoke of satellite constellations, rocket debris falling out of control, methane tank explosions, and other things that looked like an abomination.
The obvious choice was Konstantin Tsiolkovski's concept. They would build a space elevator.
The material for this was already at hand. In fact, it was because they wanted so much more from it that they were going back to space. Carbyne wires.
It didn't take long for them to have a dispute: where to build the elevator? America? Africa? Indonesia? When Parliament was about to split so they decided on six elevators equidistant along the equator: Belem, Libreville, Maleh, Gebe, Phoenix and Darwin. To top it off, they approved the suggestion brought by Arthur Clarke almost 100 years earlier in The Fountains of Paradise a gigantic orbital ring connecting the elevators.
With so many minds now turned to space it was not a surprise when the technology to alter the orbits of asteroids and comets was improved and put to use. From the elevators it was very cheap to launch probes to reach the outer solar system that take blocks of ice from trans-Neptunian orbits towards the inner solar system. The dream of terraforming Mars and Venus was within reach. Launching many of them on Mars to recover the light elements lost in eons became a university project. Bringing in large chunks of rock and ice with enough energy to speed up Venus's rotation now just required patience.
If previously people sought to detect asteroids close to Earth to prevent a collision, now they wanted to find them in order to disassemble them into their basic elements.
The base industry was all moved to the Arthur Clarke geostationary ring. This made it necessary to create comfortable dwellings for human beings. Several housing models had already been imagined, designed, tested. The O'Neill Cylinder was the most promising, but was discarded because of the Coriolis effect: the difference in gravity between the feet and heads of the inhabitants was greater than desired.
The station model chosen is a colossus: 45 km in diameter, 5 km wide. 300 meter high domes, self-sufficient with gas and water cycles complete and a controlled biosphere. Capacity for 200,000 permanent residents, or support 1 million under emergency conditions. Earth's gravity is emulated with a rotation every 300 seconds, 2.84 TWH of installed capacity in solar panels. Industrial installations that benefit from less gravity are placed between the living space and the central axis of the station, where the connection of the station with the elevators and with the surface of the Earth is made.
The stations multiply, the controlled environment for the industry is a factor. The idea of turning such an station into a kind of resort, like a private island appeals to others. Certain groups driven by a different religion, ideology or philosophy express interest. The complete structure of the Clarke ring is capable of supporting almost 16,000 stations, the materials are almost all already in space and the Earth's surface is getting cleaner.
Some even more eccentric ones act criminally and disconnect the stations of the ring. They call themselves Wanderers and love to paraphrase Carl Sagan, while earthlings call them pirates.
In 2117, human beings finally set foot on Mars and this made the planet a place of pilgrimage. Muslims visit the vallis marinellis, which they call the Prophet's Valley. Buddhists dream of a retreat on top of Olympus and Christians see on Mars - red like jasper - the Celestial Jerusalem promised since the times of John the Evangelist. A stationary ring is built around Mars and the Catholic Church provides 12 space elevators, the 12 gates of Celestial Jerusalem. In the name's dispute they decide to call them by the names of the apostles rather than the tribes of Israel, and sponsor mass immigration of Christians from Earth to Mars, for, as Pope Leo 14 stated in 2142: "Jesus said that the His kingdomis not of this world, the Earth; so we must make another world the kingdom of Our Savior". One billion people emigrate from Earth to Mars over the next 100 years.
Thus the Earth became increasingly uninhabited.
And even with all the motivations given: controlled industrial environment, ease of obtaining raw materials, isolated communities, wealthy resorts, this still seems insufficient motivation to have 16,000 space stations in space (or 20,000 if you count the Martian, lunar and wandering).
Sorry for the long winded, the question, finally:
What else would motivate humans to inhabit these space stations? What socioeconomic force would attract them?
In 2240, 10,893 stations are built and they estimate to build another 5,079 by 2300. 773 million people live in them. There are another 1 billion humans on Mars (surface and ring) and another 10~50 million in wandering stations (government agents on Ceres and Vesta plus mining companies on the asteroids, aside the pirates). Why would about 1 in 5 earthlings prefer to live in these stations than on the Earth's surface and still motivate the construction of so many?
==========
Some details that answers and comments make it necessary to add:
Slow population growth from a population that is only a fraction of that it once was makes the live standard on Earth high and enjoyable for all.
The Christian exodus to Mars begins (~2140) shortly after the construction of the first stations in Earth's orbit (~2112) and this already creates a depopulation problem on the planet. Out of every 9 people, 2 will move to Mars.
The industrial activity does employ a lot of people, but still proportionally less than today where they are 10 ~ 12% of the workforce, therefore, not all the manufacturing industry in orbit will be a reason for this.
Low-gravity activities are easy to have, there are low-gravity stop stations in space elevator sessions, and like any entertainment activity, it will share attention with dozens of others.
Fashion works both ways: there will be Earth people willing to live in bucolic stations with the bored same weather and no rain just as there will be station-born people preferring a more diverse life on the surface.
The enormous depopulation of the surface makes cities want to attract as many people as possible, in addition to wanting to retain. Even the pope's religious call to change of planet will be evaluated by millions of Christians in their pros and cons with offers of permanence in Recife, Boston, Lisbon, Chennai or Abidjan.
Yet with all that, the equivalent of the entire population of Europe, or half of China, would rather live in orbit than on the surface of planets. Why?
=========
Kinda offtopic, answer the comment:
In the expedition to Mars in 2117 Alhazred, Carlson, Jackson, Hamilton, Lösch and Xuesen explore a cave in Nectaris, in the middle of the canyons of the Vallis Marinellis and find signs in Arabic dating from about 1500 years before, as well as strange vitrified black rocks in Mars that resemble the Kaaba.
Investigations confirm authenticity (Alhazred and Jackson had nothing to do with it) and create a commotion: how or what would have done it? What else would there be to investigate and now it was submerged in the protooceans of Mars?
Legends about Muhammad are revised. The idea that the Prophet lay somewhere between Heaven and Earth took on new meaning. The inscription saying in classical Arabic "From here I departed" was incontrovertible proof that the Al Aqsa mentioned in the Holy Quran was nowhere in Arabia, Jerusalem or elsewhere on Earth. It really was "the furthest".
This also brought up the old suggestion that the relief of the valleys somehow forced the name of the Prophet inscribed on the Martian surface, something that the current coastline reinforced.
Thus, without delay, Islamic law jurists proclaimed that every Muslim who has already performed the Hajj to Mecca should, as far as possible, try to make the pilgrimage to Al Aqsa on Mars.
However, Muslims are discouraged from living on Mars. Martian children will never be able to set foot on Earth and this prevents the main pilgrimage to Mecca.

