Rio became the port for these minerals ( gold & diamonds) and replaced Salvador, north of Rio, as the main city in the colony in 1763. When Napoleon invaded Portugal, the Royal Family moved to Brazil and made Rio capital of the Kingdom ( so it was the only city outside Europe to be capital of a European Country).
When Brazil became independent in 1822, it
adopted Monarchy as its from of government (with Emperors Pedro I and
Pedro II). Many historians and Brazilians from other places say
"cariocas" are nostalgic of the Royal and Imperial Times, which is
reflected in many places.