¡La Esquina de la Gramática! Rule 25

The letter “erre” is duplicated in certain derivative and compound words
According to Ortografia de la Lengua Española, the letter “erre” represents two different sounds: the one we pronounce when saying words like ara, orilla or herir, and the sound on the words rata, arroyo or erre. To represent the last sound, when the letter “erre” is placed between two vowels, it needs to be duplicated (rr), as in perro, which sounds different tan pero.
For compounds words, where the first word ends with a vowel, and the second words starts with “erre”, you need to duplicate the “erre” to keep its sound: anti + reumático should be antirreumático.
Source http://www.banrepcultural.org