As you may know in 1964 there was a military coup in Brazil, sponsored by the US government that feared an expansion of sovietic influence in Latin America after the cuban revolution. The coup spawned a military dictatorship that lasted for more than 2 decades. Although the military government wasn't as brutal as they were in near countries as Argentina and Chile, during their years practises such as kidnapping, torture and executions were widespread. The government was VERY right wing inclined and most of the persecuted people were leftists and many of those were driven to exile (the government slogan during the dictatorship was "Brazil: love it or leave it").
Then came the re-democratization process, which started in 1985. People were clamoring for direct elections for president. Two of the major players in the process were Tancredo Neves and Luís Inácio Lula da Silva (Lula). After much discussion the congress agreed in making Neves the first civilian president since the coup and that a new constitution should be drafted in 1988. In a major plot twist Neves got very sick days before his inauguration and died without ever being able to take office. His VP was José Sarney a man that was much closer to the dictatorship and that didn't represent the shift people expected.
As predicted in 1988 a new constitution was drafted and the first general election in 25 years was held in 1989. The campaign between the right inclined Fernando Collor de Mello of the National Reconstrucion Party (PRN) and the syndicalist Lula of the Worker's Party (PT) was very controversial with many accusations from both sides. The campaign was neck to neck until Collor said that Lula would freeze every saving's account in the country if he were to win, this claim was enough to elect Collor. By then Lula and PT were considered the new left in Brazil, a breath of fresh air after many years of heavy government oppression and corruption. Lula was expecting support from another party in the election, the Brazil's Social-Democracy Party (PSDB), when they refused to take sides Lula felt betrayed.
After a huge corruption scandal (and freezing the saving's accounts) Collor was impeached and his VP Itamar Franco took office. The years after Collor saw a huge economic crisis in Brazil with massive inflation (more than 30 percent a month) and little to no growth. The minister of finance, PSDB's Fernando Henrique Cardoso (FHC), devised a plan that ultimately lifted Brazil from the crisis.
FHC's popularity went through the roof and he was elected president in 1994, against Lula himself. After the betrayal, PT was a very harsh opposition to FHC's government blocking or stalling many projects. This widened the rift between PT and PSDB. The 1988 constitution didn't allow a reelection of a president, but PSDB pushed a constitutional amendment and FHC was reelected in 1998. The amendment process was very controversial with many corruption accusations and a vote buying scandal. This made Lula seem as a moral high ground in Brazil.
Come 2002 and Lula is finally elected president of Brazil, there was a fear and perception of economic inability that severely devalued the Real right before his inauguration. This fears proved ultimately wrong and Lula was seen as a great president until 2005. In June 2005 the Mensalão scandal broke. In short the Mensalão scandal was about high government officials paying congressmen to vote according to PT wishes. This shattered the perception that PT was unblemished morality wise, but Brazil was going through an excellent economic period and the scandal wasn't enough to avoid Lula's reelection. Lula's second term wasn't as eventful as his first and towards the end he had massive approval ratings. He even stated that he could elect a light post as president if he wanted to.
Enter the light post. In 2010 Lula pushed for the nomination of his Chief of Staff Dilma Roussef as PT's presidential candidate. Dilma was tortured during the dictatorship but never held elected office before. She was then elected and became Brazil's first woman president. In early 2014 a new corruption scandal broke with the Federal Police's operation Car Wash which revealed a cartel between construction companies and Petrobras, the government's oil company and Brazil's largest company. This is the largest corruption scandal ever in Brazil in terms of money, with most parties involvement. Then it came the 2014 general elections, bidding DIlma against PSDB's Aécio Neves (Tancredo Neves grandson). It was, for the lack of a better word, a shitstorm. In the debates namecalling and lying were frequent, questions were avoided and very few topics were discussed again and again without any kind of advance. This election polarized the country in a way never seen before. People voting for Neves said that PT was corrupt and shouldn't be trusted (which was probably true) and people voting for Dilma said that Neves wasnt any better with many corruption scandals associated with him and even a DUI under his belt (which was also true). Dilma ended up winning with 51,6% of valid votes.
Brazil is also going through an economic crisis and inflation and unemployment are going up. This combined with the corruption scandals created a perception that Dilma and PT should not be in power, at least for a very large slice of the populace. It's important to remember that most of the people in these protests are white, mid/high-class and right inclined so it's not a general feeling that every Brazilian share.
TL;DR PT was seen for many years as the moral compass of Brazil. After their rise to power they took part in many corruption scandals, this combined with an economic crisis and a very polarizing election in 2014 created a feeling in a lot of Brazilians that Dilma and PT should not be in power.