Brazilians speak Portuguese because the country was once a colony of Portugal. The small European country ruled the much larger South American country for over 300 years. Brazil finally gained its independence in 1822.
Pedro Alvares Cabral claimed Brazil for the Portuguese Empire on April 22, 1500, though it took about 34 years for the country to be colonized. The Portuguese king, Dom Joao III, split the country up into 15 Captaincy Colonies, though this project failed. The King then later arranged the colonies under a Governorate General. In 1807, under the threat of Napoleon and the Spanish, the Portuguese royal court actually removed to Brazil. The move was temporary, for it was considered unseemly for the monarchy to have its court in a colony.
Though the Brazilians resented being ruled by Portugal, they named the King's son, Prince Dom Pedro, as their emperor when they eventually gained independence. Portugal finally recognized the new country on August 29, 1825. After more strife, even Dom Pedro abdicated in favor of his son, who was 5 years old at the time.
As of 2014, Portuguese remains the official language of Brazil. Nearly everyone speaks it, and it's the only language used in mass communications. Portuguese Brazilian is different than European Portuguese, but the differences are minor.