Great question — answering as the UphillTech team:
I think the answer has to do with competition. If you want to fly from Madrid to Rio de Janeiro with one stop, you have lots of options. You can fly TAM (via Sao Paulo), TAP Portugal (via Lisbon), American (via New York or Miami), KLM (via Amsterdam), Air France (via Paris), etc, etc. (I found these with Kayak.) There is a lot of competition and this will tend to drive fares down. However, if you want to fly from Madrid to Sao Paulo nonstop, your only choices are TAM, Iberia, and (somewhat surprisingly) Air China (though only twice a week). There is less competition, so fares may tend to be higher, and this may exceed the effect of the cost of the extra flight GRU-GIG. As a more exaggerated...
Full answer by Nate Eldredge: https://travel.stackexchange.com/a/5410 (CC BY-SA 3.0).
Need it done for your business? UphillTech.