Option 1: It becomes cheaper to build luxury space habitats than luxury apartments in New York City
You want it to make economic sense to build space habitats and for people to get in them, so the first option is that it somehow becomes cheaper to build space habitats than expensive apartments in an expensive city.
This is notionally possible because completely automated construction projects in space won't have to worry about pesky things like environmental impact, so they MIGHT be able to overcome the costs of construction on earth by building the habitats out of asteroids or some such nonsense.
Option 2: It becomes objectively better to live in a space habitat
We're doing a pretty good job of ruining the Earth. If we keep it up, then a space habitat might look pretty inviting. If we accelerate the process significantly, we could make it dangerous to stay on Earth and then everyone would want to move to a space habitat regardless of the expense.
Option 3: There is no option 3
That's it. To make economic sense, it has to be cheaper than living on Earth or demand for it has to exceed the cost.
There are other reasons than economic reasons why we might put 1 million people in space habitats, but they aren't economic ones.
Edit: Explanation of Why/How Space Habitats are the Same or Better than living in Cities
For starters, we should clear one thing up about space habitats, and that's their size and layout. A long-term space habitat MUST be a rotating ring or cylinder to provide artificial gravity (unless we invent magic artificial gravity). It MUST then rotate slow enough that no one faces adverse effects from the rotation (likely lower than 1 RPM). It is also then highly likely that a second cylinder be attached at close proximity to the first to stabilize the orientation of the cylinder.
If such a cylinder rotates at 1 RPM or less, it must have a radius of around 900m spincalc. The designs for the O'Neill cylinder assume a length 4 times the diameter, so I'll use that to give these habitats a minimum area of 20 km2 per cylinder. Since it's actually 2 cylinders attached to each other, that's 40 km2.
For population density, US metropolitan areas range from 200 persons per km2 (unless you could Anchorage Alaska, which I don't) all the way up to 10,000 persons per km2, and I suspect the population density on these cylinders might vary similarly.
Let's pick a lightly populated cylinder with 40,000 people now. How does such a cylinder compare to a city in the real world?
- In a city of that size, food is imported, so virtually all types of cuisine are available. A cylinder of that size would need to either import its food as well or use some advanced technology to grow food in a way we haven't fully realized. My money's on the technology because they're doing some really fantastic things with lab-grown products these days, but that's not important. What is important is that the food is similar.
- In a city that size, many people born in the city will never leave that city. People make fun of folks never leaving small towns a lot, but the same is true of cities. A space habitat will be largely the same because leaving the habitat during your lifetime will be prohibitively expensive.
- A population group that size can support just about any form of entertainment facility you can think of short of major sports arenas.
An O'Neill cylinder, additionally, would be built from the ground up with the interests of its residents in mind, and with every facility using state of the art technology. Quality public transportation would be built into the cylinder by default because no one is going to be bringing personal transports into space.
All in all I suspect that living in a city your entire life is very much the same as living in a space habitat your entire life, and plenty of people do the former.
Heck, with the increasing popularity and advancements in home delivery and VR, I suspect there's a large number of people who will never willingly leave their homes, let alone their home city.