Expectation of reward after taking action $a$ in state $s$ and ending up in state $s'$ would simply be
\begin{equation}
r(s, a, s') = \sum_{r \in R} r \cdot p(r|s, a, s')
\end{equation}
The problem with this is that they do not define probability distribution for rewards separately, they use joint distribution $p(s', r|s, a)$, which represents probability for ending up in state $s'$ with reward $r$ after taking action $a$ in state $s$. This probability can be separated in 2 parts using product rule
\begin{equation}
p(s', r|s, a) = p(s'|s, a)\cdot p(r|s', s, a)
\end{equation}
which represents the probability for getting to state $s'$ from $(s, a)$, and then probability for getting reward $r$ after ending up in $s'$.
If we define reward expectation through the joint distribution, we would have
\begin{align}
r(s, a, s') &= \sum_{r \in R} r \cdot p(s', r|s, a)\\
&= \sum_{r \in R} r \cdot p(s'|s, a) \cdot p(r|s', s, a)
\end{align}
but this would not be correct, since we have this extra $p(s'|s, a)$, so we divide everything by it to get expression with only $p(r|s', s, a)$.
So, in the end we have
\begin{equation}
r(s, a, s') = \sum_{r \in R} r \frac{p(r, s'|s, a)}{p(s'|s, a)}
\end{equation}