The word México originates in the Mesoamerican era with the Náhuatl word Mexihco (pronounced Meh-SHI-ko) originally referring to the Valley of México. A people called the Mexica migrated south from a place they called Aztlán, established a city on a marshy island in Lake Texcoco, then expanded their domain over the entire valley and beyond.
That valley came to be known as the land of the Mexica, or the Valley of México. The capital, Tenochtitlán, was called both Tenochtitlán and (the city of) Mexico… Tenochtitlán is difficult for Spanish speakers to pronounce, so México was adopted with a pronunciation change to fit Spanish phonetics.
When New Spain was created, it was divided into five provinces, the most important of which was — you guessed it — México, based roughly off the borders of the old Aztec Empire. México City became the capital of both the province and the colony of New Spain…
Under the social order, those born in New Spain were second in status to peninsulares (those born in Spain), yet they felt that they were the “true Mexicans.” For this reason, when independence was achieved in 1821, the choice of name for the new country was México... The use of México reflects that the identity of the country is still highly tied with the city and is reinforced by history, legends and symbols such as the eagle and cactus from the Aztec origin myth, and the Virgin of Guadalupe [La Virgen Morena, the Brown Virgin, who appeared before an Aztec peasant in 1531].