I am going to summarize 100 years in my answer which is very incomplete. Please don't take this as the final answer, and explore Brazil's incredible history yourself.
Your question has a false premise: there was indeed fracturing and it's arguable that today Brazil is a culturally and politically, if not geographically, fractured nation. To your point however, several factors - the presence of the royal family, an extremely capable second emperor, Dom Pedro II, and demographic and geographical trends - helped keep Brazil a country - if not a cohesive one - after 1822:
1 - the longstanding (1807) presence of the Royal Family of Portugal, which had been living in exile in Rio de Janeiro since Imperial French forces invaded the Iberian Peninsula. This had a major impact on the identity of Brazil as a cohesive state, if not the successor state to Portugal, and fused a Brazilian identity around the King. This became especially obvious during...
2 - the Empire of Brazil. Founded in 1822 by Dom Pedro I, son of Portuguese King Joao IV, a relatively brutal two-year war of independence was waged across the nation between forces loyal to Portugal and the new Emperor. The war was followed by a number of secessionist crises, the most notable of which - the Cisplatine War - created Uruguay. Things only got worse when Pedro I quit Brazil to press his daughter Maria's claim to the Portuguese throne. He abdicated in favor of his 5-year-old son...
3 - Dom Pedro II. After an ineffective regency and lots of discontent, Dom Pedro II assumed majority and full rulership of Brazil in 1831. Throughout his reign there were a number of crises that could have split Brazil apart, but Pedro II was an able and active ruler. He successfully steered Brazil through three wars, including the brutal Paraguayan wars. He kept Brazil united during religious tensions, dramatic and uneven economic expansion, the abolition of slavery, and even his own overthrow by a small, unpopular military clique. Dom Pedro II refused to cause a civil war over his ouster, declaring,
"If it is so, it will be my retirement. I have worked too hard and I am tired. I will go rest then."
4 - demographics. For an enormous country, Brazil has a highly concentrated pattern of settlement. Reliable demographic statistics in Brazil are notoriously hard to get, but it's estimated that by 1850, Brazil had a population of ~7.2m, over 85% of which lived in coastal cities, where communication and power could be facilitated by sea. This concentration helped dissuade regionalism, though in some cases - most notably Uruguay - it wasn't enough to prevent secession.
I hope this has helped you. Please explore Brazilian history on your own. It's very rewarding and unique for the New World.