Answer
$$\displaystyle{\int\frac{x^2+1}{\left(x^2-2x+2\right)^2}dx=\frac{x-2+\left(x-1\right)^2}{2\left(x^2-2x+2\right)}+\frac{3}{2}\arctan\left(x-1\right)+C}$$
Work Step by Step
$\displaystyle{I=\int\frac{x^2+1}{\left(x^2-2x+2\right)^2}dx}\\
\displaystyle{I=\int\frac{x^2+1}{\left(\left(x-1\right)^2+1\right)^2}dx}\\
$
$\displaystyle \left[\begin{array}{ll} x-1=\tan\theta & \left(x-1\right)^2=\tan^2\theta \\ & \\ \frac{dx}{d\theta}=\sec^2\theta & dx=\sec^2\theta\ d\theta \end{array}\right]$
Integration by substitution
$\displaystyle{I=\int\frac{\left(\tan\theta+1\right)^2+1}{\left(\tan^2\theta+1\right)^2}\sec^2\theta\ d\theta}\\
\displaystyle{I=\int\frac{\tan^2\theta+2\tan\theta+2}{\sec^4\theta}\sec^2\theta\ d\theta}\\
\displaystyle{I=\int\frac{\tan^2\theta+2\tan\theta+2}{\sec^2\theta}\ d\theta}\\
\displaystyle{I=\int\frac{\tan^2\theta}{\sec^2\theta}+2\frac{\tan\theta}{\sec^2\theta}+\frac{2}{\sec^2\theta}\ d\theta}\\
\displaystyle{I=\int\sin^2\theta+2\sin\theta\cos\theta+2\cos^2\theta\ d\theta}\\
\displaystyle{I=\int\sin^2\theta+2\cos^2\theta+2\sin\theta\cos\theta\ d\theta}\\
\displaystyle{I=\int1+\cos^2\theta+\sin2\theta\ d\theta}\\
\displaystyle{I=\int1+\frac{1}{2}\left(\cos2\theta+1\right)+\sin2\theta\ d\theta}\\
\displaystyle{I=\frac{1}{2}\int2+\cos2\theta+1+2\sin2\theta\ d\theta}\\
\displaystyle{I=\frac{1}{2}\int\cos2\theta+2\sin2\theta+3\ d\theta}\\
\displaystyle{I=\frac{1}{2}\left(\frac{1}{2}\sin2\theta-\cos2\theta+3\theta\right)+C}\\
\displaystyle{I=\frac{1}{4}\sin2\theta-\frac{1}{2}\cos2\theta+\frac{3}{2}\theta+C}\\
\displaystyle{I=\frac{1}{2}\sin\theta\cos\theta-\frac{1}{2}\cos^2\theta+\frac{1}{2}\sin^2\theta+\frac{3}{2}\theta+C}\\
$
$\sin\theta=\frac{x-1}{\sqrt{x^2-2x+2}}\\
\cos\theta=\frac{1}{\sqrt{x^2-2x+2}}\\
$
$\displaystyle{I=\frac{1}{2}\frac{x-1}{\sqrt{x^2-2x+2}}\times\frac{1}{\sqrt{x^2-2x+2}}-\frac{1}{2}\left(\frac{1}{\sqrt{x^2-2x+2}}\right)^2+\frac{1}{2}\left(\frac{x-1}{\sqrt{x^2-2x+2}}\right)^2+\frac{3}{2}\arctan\left(x-1\right)+C}\\
\displaystyle{I=\frac{x-2+\left(x-1\right)^2}{2\left(x^2-2x+2\right)}+\frac{3}{2}\arctan\left(x-1\right)+C}\\
$