City of New York and elsewhere may be losing population, but there are many reasons.
First and foremost just as with rest of country boomers are reaching retirement age, and their parents generation either are dying or becoming advanced elderly. Latter means if the kids move out of state, surviving parent or parents usually go as well.
Middle class is fleeing NYC and even Westchester or Long Island due to HCL, taxes, and simple fact areas are changing (read less white).
Families with children crunch numbers and often realize they can do far better close as New Jersey, or elsewhere. That is even if they pay more in taxes their kids can attend excellent local public schools. This and there are plenty of other amenities provided by local governments in exchange for all those high taxes.
Parts of New Jersey such as Montclair and Maplewood are now nicknamed "Brooklyn" because of all the former Park Slope and other residents of west Brooklyn who have fled to those areas. This covers both gay and straight.....
Upstate is what it is; a hot mess caused by it being part of rust belt, and despite being elected three times on promises to change things, upstate still is emptying out due to lack of good employment options. Large employers up there either have long folded, are moving, or shrinking footprints; and nothing is coming to replace. Oh and weather up there isn't that great large portions of year; especially winters which can be brutal.
None of this touches recent changes in tax code (read SALT deductions) that has uncovered NYS's tax nakedness.
For decades Albany raised taxes with a wink and nod because people could deduct some of it on their federal taxes so things sort of evened out. Now they cannot or that ability is restricted people have woken up, and are packing up.
Finally why would anyone who works hard enough to be middle class (which by the way would be considered wealthy in most areas of country), remain in NYC or even NYS? Increasingly all you get is taxed to death to support a vast and bewildering array of social services/wealth redistribution. Services such as transportation (subways, buses, etc... ) stink compared to say Paris, London, Toyko. Housing is insanely expensive for what you get (and this includes much new construction that is piss poor but costs millions to buy or several thousands in rent per month).
If you are poor, very low income, illegal immigrant or whatever, then yes, New York is a great place to be; you give very little but get much more handed over to you for free. Homeless? No problem, city will put you into brand new construction apartment for little or no cost to yourself.
People who are flocking here besides the poor are Bernie Bros and their frau equivalents (think AOC) . You're seeing proof of this in how politics are changing in areas of Queens, Brooklyn and in a limited way (for now) Bronx and Staten Island.
Lust after Matt Karp all you want; but Brooklyn is full of guys just like him politics wise, and their numbers are growing. These are relatively well paid tech and others whose relative wealth (for now) allows them to live in NYC and spread their gospel.