Are you asking how they came up with the idea to add rx to f(x) so as to convert the problem to a case where you can apply Rolle's theorem? Well, say you're given the problem:
(1) Prove that if f is differentiable on [a,b], there is some point c in [a,b] with f'(c)=s, where s is the slope of the secant line between (a,f(a)) and (b,f(b)).
(note I've called s what they've called -r) And assume further that you know Rolle's theorem, that:
(2) If f is differentiable on [a,b] and f(a)=f(b), then there is some point c in [a,b] with f'(c)=0.
Then you'll notice that (1) has a very similar structure to (2), and in fact, (1) is a special case of (2). So you'd naturally ask if there's a way to use (2) to prove (1).
(Actually, to be fair, I would probably first look at the proof of (2) to see if I could modify it to get (1). It's usually not the case that you can just use the statement of a specific theorem to prove a more general theorem, although there are other examples. You just get lucky in this case)
Next, you know the derivative of f(x)+g(x) is f'(x)+g'(x). You also might notice that if you subtract the secant line, h(x)=sx, from f(x), then f(x)-h(x) has f(a)-h(a)=f(b)-h(b) (this can be seen geometrically, since h(x) intersects f(x) at a and b, so in fact f(a)-h(a)=f(b)-h(b)=0). Then you can apply Rolle's theorem to f(x)-h(x), and see there is some point c with f'(c)-h'(c)=0, or f'(c)=h'(c)=s. I'm not sure if this answers your question.