A CPF ( Cadastro De Pessoa Fisicas) is an individual taxpayer ID that you should probably consider getting if you stay in Brazil for a long period, say about more than 120 days, it's not necessary to get a CPF but it's important since you'll it need to open bank accounts, get loans and credit cards, trade in real estate, apply for jobs and get a driving license. Basically, it's essential for almost every formal service in Brazil.
How to apply for a CPF
Places where you can apply for a CPF include
Banks- Banco do Brasil and Caixa econômica federal
Post offices (correios)
In some post offices, like the one I went to in Belo Horizonte, they use queue ticketing system, be sure to print out the ticket for the right service ( outros servicio) because they'll make you print another ticket and wait in line again if you get the wrong ticket.
Once you're given the CPF application form they'll ask for:
Your passport
Proof of residency in Brazil - declaration from your host, water bill, or electricity bill.
You'll then pay a fee of R$7 then proceed to Receita federal ( Inland revenue). They use queue ticketing and issue a limited number of tickets to the people who'll be getting the service that day, so I had to be there by 6 a.m to be sure I get the ticket.
Present your receipt and passport to the attendant. They'll print out your CPF for you.