Rio presents a particular problem with regard to safety, the favelas and better-off areas are very close together, to the extent that if you take the right turn at the fork in the road, you'll get home, take the other and you might end up dead.
You would probably need to live outside Rio, some place like Barra da Tijuca, to live a more relaxed life.
Or live in Sao Paulo, where there's more distance to the favelas, with large safe areas (avoid the city centre), and you get an amazing multicultural experience (it's not just Liberdade). Plus you can drive down to the beach any weekend you like, or take the "ponte aerea" to Rio. I saw some hate being expressed about Brazilians, but SP is a very organized city, at least in the better off areas.