Answer
$$y(x)=\frac{1}{x+1}\left(5+\ln x-\frac{1}{x}\right)$$
Work Step by Step
Given $$y^{\prime}+\frac{1}{x+1} y=x^{-2}, \quad y(1)=2$$
This a linear equation with $p(x) =\frac{1}{1+x}$ and $q(x) =x^{-2} $, so
\begin{align*}
\mu(x) &= e^{\int p(x)dx}\\
&=e^{\int\frac{1}{1+x} dx}\\
&= e^{\ln (1+x)}\\
&=1+x
\end{align*}
Hence the general solution is
\begin{align*}
\mu(x) y &=\int \mu (x)xq(x)dx\\
(1+x) y&=\int (1+x)x^{-2}dx \\
&=\int \frac{1}{x}+ x^{-2}dx\\
&=\ln x- x^{-1}+C
\end{align*}
Then $$ y(x)=\frac{1}{x+1}\left(C+\ln x-\frac{1}{x}\right)$$
Since $ y(1)= 2 $, then $C=5$, and hence
$$y(x)=\frac{1}{x+1}\left(5+\ln x-\frac{1}{x}\right)$$