"Let us always remember this: Only when we are able to share, do we become truly rich," he told the large crowd, including slum residents, gathered in the soccer stadium. "Everything that is shared is multiplied!"
Even in Varginha, a neighborhood where poverty, drugs and violence had run rampant, hope must continue, he said.
"Situations can change, people can change. Be the first to seek to bring good; do not grow accustomed to evil but defeat it."
Later Thursday, the pope was to lead a religious service on Copacabana Beach, with upward of 1 million Catholics expected to attend.
CNN's Barbara Arvanitidis, Hada Messia and Daniel Burke contributed to this report.