Why is Mexico city the largest city in Mexico?

The Mexico City Valley is part of the Central Mexican Plateau, a region with temperate climate and rich volcanic soil -- unlike the arid deserts to the north and the suffocating jungles to the south. Since several thousand years ago, this combination of climate and fertile soil has allowed better agricultural yields and in turn, greater population densities.
Nowadays, Mexico City is extremely big due to an over-centralization of political and economic power, and more social openness (for example, same-sex marriage in Mexico was first approved in Mexico City on 2009) since colonial times.

These factors have contributed to increased immigration from other areas of the country.