Solution (source code)

= Solution

For normalized <Legendre polynomials>, $P_n(1)=1$ and $P_n(-1)=(-1)^n$. Near the endpoints the integral factor has the asymptotics
$$
\int^x\frac{dt}{(1-t^2)P_n(t)^2}=-\frac12\log|1-x|+O(1)\quad(x\to1),
$$
and
$$
\int^x\frac{dt}{(1-t^2)P_n(t)^2}=\frac12\log|1+x|+O(1)\quad(x\to-1).
$$
Thus an independent solution, for which $C_2\ne0$, has the logarithmic endpoint singularities
$$
\boxed{y=-\frac{C_2}{2}\log|1-x|+O(1)\quad(x\to1),\qquad y=\frac{(-1)^nC_2}{2}\log|1+x|+O(1)\quad(x\to-1).}
$$
The constants are understood for a solution continued consistently across the ordinary interior points. Adding any multiple of $P_n$ cannot cancel these logarithms. This explains why boundedness at an endpoint selects the <Legendre polynomial> and excludes the independent <Legendre function of the second kind>.