I'm a little confused about the domain/range $S\to R...$ I would think it would just be from the reals to the reals. But, anyway, by function, they mean... function. I don't know another way to put it. Just a function like $r(X)=X^2$ or any other example. The key is that the property holds for any function.
The quickest way to see that the left side equals the right is that $$ r(X)E(Y|X) = E(r(X)Y|X)$$ since you can always pull something conditioned on out of a conditional expectation (when it's conditioned on, it's effectively constant). So plugging this in, we have $$E(r(X)E(Y|X))=E(E(r(X)Y|X)) = E(r(X)Y) $$
where the second equality is the law of total expectation.