$\displaystyle xy''-y'=-\dfrac{2}{x^2}$
The integrating factor is $\displaystyle \dfrac{1}{x^3}$, so multiply both sides by that:
$\displaystyle \dfrac{1}{x^2}y'' - \dfrac{1}{x^3}y' = -\dfrac{2}{x^5}$
$\displaystyle \left(\dfrac{y'}{x^2}\right)^\prime = -\dfrac{2}{x^5}$
Integrating both sides:
$\displaystyle \dfrac{y'}{x^2} = -\int \dfrac{2}{x^5}dx = \dfrac{1}{2x^4}+C_1$
Multiply both sides by $\displaystyle x^2$:
$\displaystyle y' = \dfrac{1}{2x^2}+C_1x^2$
Integrate both sides:
$\displaystyle y = -\dfrac{1}{2x}+\dfrac{C_1x^3}{3}+C_2$
Fold the $\displaystyle \dfrac{C_1}{3}$ into a single constant:
$\displaystyle y = c_1x^3-\dfrac{1}{2x}+c_2$
When you entered the problem into WolframAlpha, you entered $\displaystyle xy''-2y' = -2/x^3$. Notice the RHS of that differential equation has $\displaystyle x^3$ in the denominator. Your original problem has $\displaystyle x^2$ in the denominator.
You are correct that the general solution to the associated homogeneous equation is $\displaystyle y= C_1x^3+ C_2$ but you are doing the "variation of parameters" incorrectly.
Yes, we look for a solution to the entire equation of the form $\displaystyle y= C_1(x)x^3+ C_2(x)$, allowing the "parameters", $\displaystyle C_1$ and $\displaystyle C_2$ to "vary".
Then we have $\displaystyle y'= C_1'x^3+ 3C_1x^2+ C_2'$. We simplify the equation (there are many different possible functions for $\displaystyle C_1$ and $\displaystyle C_2$) by requiring that $\displaystyle C_1'x^3+ C_2'= 0$ leaving $\displaystyle y'= 3C_1x^2$. Differentiating again, $\displaystyle y''= 3C_1'x^2+ 6C_1x$ and now the differential equation becomes $\displaystyle xy''- 2y'= 3C_1'x^3+ 6C_1x^2- 6C_1x^2= 3C_1'x^3= -\frac{2}{x^2}$.
There is your error- you have, although you don't say how you arrived at it, $\displaystyle x^2$ on the left rather than $\displaystyle x^3$.
Can you explaint this part? And why you wrote y' instead of 2y' and got right answer?
$\displaystyle \dfrac{1}{x^2}y'' - \dfrac{1}{x^3}y' = -\dfrac{2}{x^5}$
$\displaystyle \left(\dfrac{y'}{x^2}\right)^\prime = -\dfrac{2}{x^5}$