Map from Google - Rio_de_Janeiro

In Rio de Janeiro, a big city of Brazil and capital of the state of the same name, the climate is tropical, with a relatively cool season from May to October, and a hot and muggy season from December to March, with November and April as intermediate months. The average temperature of July is 21.5 °C (70.5 °F), that of January and February is 27 °C (81 °F).
The city lies on the coast: the famous beaches of Copacabana and Ipanema are located along the coast of the Atlantic Ocean, while the city overlooks the Guanabara Bay, where there is also the Rio de Janeiro-Galeao airport, named after Antônio Carlos Jobim. Around the city there are hills covered with forests, reaching about a thousand metres (3,300 feet) of altitude. Mount Corcovado, or Monte Cristo, on top of which is the famous statue of Christ the Redeemer, is 710 metres (2,329 feet) high, which means that on the summit the temperature is about 4 degrees Celsius (7 °F) lower than on the plains. The Sugarloaf Mountain, accessible by a cable car with a stunning view, is instead at the entrance of the bay, and is 396 metres (1,300 feet) high.
Here are the average temperatures (recorded along the coast, in the Saúde district).
Average temperatures - Rio de Janeiro
Rio de JaneiroJanFebMarAprMayJunJulAugSepOctNovDec
Rio de JaneiroJFMAMJJASOND
Min (°C)232423222019181919202122
Max (°C)293029282625252625262729
Min (°F)737573726866646666687072
Max (°F)848684827977777977798184

Although the average temperatures are not very high, and thankfully the breeze usually blows, relieving the heat, sometimes in summer very hot days can occur, with highs around 35/37 °C (95/99 °F), from October to April; however, summery days can also occur in winter, with highs around 30/32 °C (86/90 °F) even in June, July and August.
On the other hand, during the cool season, from May to October, cold air masses of Antarctic origin can bring cool temperatures, or even a little cold at night, so that lows can drop to around 10/12 °C (50/54 °F), and highs can stay around 18/20 °C (64/68 °F). This happens in the city proper, in the districts lying along the coast, but in the localities of the metropolitan region situated to the north-west and far from the sea, like Nova Iguaçu, lows can drop even below 10 °C (50 °F).

Cable car to Sugarloaf Mountain

The rains amount to around 1,050 millimetres (41.5 inches) per year, so they are relatively abundant; the wettest season is summer, from December to March (remember that the city is located in the Southern Hemisphere), when the rains mainly occur in the form of showers or thunderstorms. The winter season is quite dry, but at times some disturbances can pass, bringing some days of bad weather, and also cool temperatures: this happens mostly in winter (in the months of June, July and August), but can also occur in the months of May, September and October (which are not so different).
Here is the average precipitation.
Average precipitation - Rio de Janeiro
Rio de JaneiroJanFebMarAprMayJunJulAugSepOctNovDecYear
Rio de JaneiroJFMAMJJASONDY
Prec. (mm)135130135957045404555851001351070
Prec. (in)5.35.15.33.72.81.81.61.82.23.33.95.342.1
Days11789664579101193

The amount of sunshine in Rio is good, but not great. In summer, the sky is often clear or partly cloudy, but some cloud banks can form, more or less intense, associated, as mentioned, with showers and thunderstorms: there are on average 7 hours of sunshine per day from January to March. In winter, the relatively dry season, as I said there can be some cloudiness linked to depressions: there are about 6 hours of sunshine per day from June to August, and 5 in September and October.
Sunshine - Rio de Janeiro
Rio de JaneiroJanFebMarAprMayJunJulAugSepOctNovDec
Rio de JaneiroJFMAMJJASOND
Sun (hours)777666665566

The sea is warm enough for swimming from November to May, when its temperature is equal to or higher than 24 °C (75 °F), or even in June, when it drops to 23 °C (73 °F); from July to October it is a bit cool, but not impossible after all, since it remains around 22 °C (72 °F).
Here are the average sea temperatures.
Sea temperature - Rio de Janeiro
Rio de JaneiroJanFebMarAprMayJunJulAugSepOctNovDec
Rio de JaneiroJFMAMJJASOND
Sea (°C)252626252423222222222425
Sea (°F)777979777573727272727577

When to go

The best time to visit Rio de Janeiro is winter, from May to October: temperatures are generally pleasant, with quite rare rains. It will be possible to pass a relaxing time on the beaches, to sunbathe, and to try to swim in a sea a little cool. A sweatshirt and a light jacket can help for the evening and on cool and cloudy days.
In summer the weather is hot and muggy, sometimes very hot, and thunderstorms can break out, but there is also a lot of sunshine. As there is no danger of the passage of cyclones, if you want you can go in this season as well, at least if you do not suffer from the heat, and you have in mind long periods on the beach. It may be useful to book a hotel with air conditioning, and bring a sweatshirt or a pashmina for airconditioned places.