Let $$y = \mathrm{e}^x \cdot \frac{x^3 - x + 2}{(x^2 + 1)^2} = f'$$ for some function $$f$$.
If we then write $$f = \mathrm{e}^x q$$ for some function $$q$$ and differentiate this we see that $$f' = \mathrm{e}^x (q + q')$$. Thus we can write
$$\mathrm{e}^x \cdot \frac{x^3 - x + 2}{(x^2 + 1)^2} = \mathrm{e}^x (q + q') \quad \Leftrightarrow \quad \frac{x^3 - x + 2}{(x^2 + 1)^2} = q + q'$$.
This could be solved directly, but I liked more to do this light differently like this:
Now I assume that function $$q$$ can be written in form $$q = \frac{p}{x^2 + 1}$$ using some function $$p$$. Substituting this into the equation gives us
$$(x - 1)^2p + (x^2 + 1)p' = x^3 - x + 2$$.
This ODE is easy to solve. For homogenous equation we obtain
$$p_h = C\mathrm{e}^{-x}(x^2 + 1)$$
and particular solution
$$p_p = x + 1$$,
and thus the solution to the ODE is
$$p = x + 1 + C\mathrm{e}^{-x}(x^2 + 1)$$.
Now we can write the functions $$q$$ and $$f$$, namely
$$q = \frac{p}{x^2 + 1} = \frac{x + 1}{x^2 + 1} + C\mathrm{e}^{-x}$$
and
$$f = \mathrm{e}^x q = \mathrm{e}^x \cdot \frac{x + 1}{x^2 + 1} + C$$.
Hence
$$\int \mathrm{e}^x \cdot \frac{x^3 - x + 2}{(x^2 + 1)^2} \mathrm{d}x = \mathrm{e}^x \cdot \frac{x + 1}{x^2 + 1} + C$$.