Why does integrating $\int\frac{\left(x+q_{2}\right)^{s_{2}}}{\left(x+q_{1}\right)^{s_{1}}}dx$ involve hypergeometric functions? Consider the following integral, derived from Kullback-Leibler divergence,
\begin{equation}
\int \frac{1}{(x+q_1)^{s_1}}\log_2\left(\frac{\left(x+q_{2}\right)^{s_{2}}}{\left(x+q_{1}\right)^{s_{1}}}\right)dx
\end{equation}
WolframAlpha produces a solution in terms of the hypergeometric function. How does this come about? Note that the hypergeometric function denoted by ${}_2 F_1$. The combinatorial form after substituting for $u=x+q_1$ might help:
\begin{equation}
\frac{(u-q_1+q_2)^{s_2}}{u^{s_1}}=\frac{\sum_{n=1}^{\infty}u^n\binom{s_2}{n}(q_2-q_1)^{s_2-n}}{u^{s_1}}.
\end{equation}
 A: Our goal is to see why hypergeometric functions end up in the solution to the integral
$$
I=\int \frac{1}{(x+q_1)^{s_1}}\log_2\left(\frac{\left(x+q_{2}\right)^{s_{2}}}{\left(x+q_{1}\right)^{s_{1}}}\right)dx.
$$
Letting $\log z$ denote the natural logarithm we have by the change of base formula $\log_2z=\log z/\log2$. Then utilizing properties of logarithms, we are able to write $I$ as
$$
I=\frac{s_2}{\log 2}\int \frac{\log(x+q_2)}{(x+q_1)^{s_1}}\,\mathrm dx-\frac{s_1}{\log 2}\int\frac{\log(x+q_{1})}{(x+q_1)^{s_1}}dx.
$$
The second integral is easily evaluated in terms of elementrary functions yielding
$$
I=\frac{s_2}{\log 2}\underbrace{\int \frac{\log(x+q_2)}{(x+q_1)^{s_1}}\,\mathrm dx}_J-\frac{s_1}{\log 2}\frac{\left(q_1+x\right){}^{1-s_1} \left(-s_1 \log \left(q_1+x\right)+\log
   \left(q_1+x\right)-1\right)}{\left(s_1-1\right){}^2}.
$$
All that is left is to evaluate $J$. Integrating by parts with $u=\log(x+q_2)$ and $\mathrm dv=(x+q_1)^{-s_1}\,\mathrm dx$ we find
$$
J=\frac{1}{1-s_1}\frac{\log(x+q_2)}{(x+q_1)^{s_1-1}}-\frac{1}{1-s_1}\underbrace{\int \frac{x+q_1}{x+q_2}\frac{1}{(x+q_1)^{s_1}}\,\mathrm dx}_{J^\prime}.
$$
Note that $J^\prime$ is the integral found in the title of this post. Evaluating $J^\prime$ is done by means of a substitution. Substituting $u=(x+q_1)/(x+q_2)$ we obtain
$$
J^\prime=\int((q_2-q_1)u)^{1-s_1}(1-u)^{s_1-2}\,\mathrm du.
$$
Performing a second substitution of $t=(q_2-q_1)u$ further gives
$$
J^\prime=\frac{1}{q_2-q_1}\int \frac{t^{1-s_1}}{(1-zt)^{2-s_1}}\,\mathrm dt,
$$
where $z=(q_2-q_1)^{-1}$. By the fundamental theorem of calculus this is equivalent to
$$
J^\prime=\frac{1}{q_2-q_1}\int_0^t \frac{v^{1-s_1}}{(1-zv)^{2-s_1}}\,\mathrm dv,
$$
which upon substituting $w=v/t$ gives
$$
J^\prime=\frac{t^{2-s_1}}{q_2-q_1}\int_0^1 \frac{w^{(2-s_1)-1} (1-w)^{(3-s_1)-(2-s_1)-1}}{(1-ztw)^{2-s_1}}\,\mathrm dw.
$$
Comparing this result to DLMF 15.6.1 then allows us to evaluate $J^\prime$ in terms of the hypergeometric function $_2F_1(2-s_1,2-s_1;3-s_1;\cdots)$. The form given by WA can then be obtained using transformation of variables for the hypergeometric function.
