The net income shown is extremely misleading. Open the economic details window of the city. Put the mouse over the various types of expenditures and you'll see why the city appears to be losing money. Big cities are arbitrarily assigned more maintenance. This is for show only, it has no effect on your actual economy.

Suppose a big city loses population due to plague (for example). Some of it's troop maintenance will be reassigned to other cities. The plagued city will appear to make more money but the rest of your cities will be shouldering more maintenance - your overall economy will be weaker.

If you ignore maintenance and compare income, a 24,000 city does make far more money than a 6,000 city.