Why is NYC so much more expensive?
Because people can make more money to spend on more housing in NYC...
NYC metro population grows from 18.3 to 19.8M (8%) [2].
It's harder for NYC to under-build for a century when the population has not grown as much. Chicago isn't exactly a developer's utopia...
[1] https://www.macrotrends.net/cities/22956/chicago/population
[2] https://www.macrotrends.net/states/new-york/population
If you isolate just the city - NYC does grow from 7.8M to 8.8M (12%). Manhattan goes from 1.54M to 1.69M (9%).
Chicago's downtown population growth is >40%.
In any case, though, the original question is whether population density actually makes a place less desirable. The mere fact that Chicago is not cheap (not simply inexpensive, but actually cheap) contradicts the claim that population density is something people don't want.
They don't want density for the sake of density.
NYC has better opportunities - that's why it's denser. It's not denser because it's more desirable, and then it just so happens that it also has opportunity.
This is true for Shenzhen and Beijing and Mexico City and Paris and London and Mumbai and every major city.
NYC is located at the mouth of the Hudson and one end of Long Island sound, two relatively sheltered waterways. For hundreds of years this facilitated huge amounts of resource extraction from the region. Upon this resource extraction economy resource processing was built. Naturally it was located where the labor was the the products flowed through, the port. From there industrialization and an industrialized economy way built upon the resource processing. Through little other than historical luck of geography of the industries (that really took hold in NYC was finance. It has been that finance industry that has carried NYC through the transition to a service economy.
So basically, NYC is valuable today because it was yesterday and if you follow the recursion back to the base case you find natural resources.
While the natural resources are now gone or irrelevant they were the startup capital for the NYC we have today. There is no inherent value to a mass of people unless there is some productive activity for them to engage in. NYC got lucky and developed a finance industry. See Detroit for what happens when you don't make the transition.