Answer
$y=\frac{t^2}{4}-\frac{t}{3}+\frac{1}{2}+\frac{1}{12}$
Work Step by Step
$ty'+2y=t^2-t+1$
To get in form $\frac{dy}{dt}+ay=g(t)$ divide by t
$y'+\frac{2y}{t}=t-1+\frac{1}{t}$
$\frac{d\mu}{dt}=\frac{2}{t}\mu(t)$
$\int{\frac{d}{dt}(ln(\mu(t)))}dt = \int{\frac{2}{t}}dt$
$ln(\mu(t))+c_1 = 2ln(t)+c_2$
Combine constants
$\mu(t) = t^2e^{c}$
Multiply by $\mu$
$t^2e^c(y'+\frac{2y}{t}=t-1+\frac{1}{t})$
The term $e^c$ cancels out
$t^2y'+2ty=t^3-t^2+t$
$\int{\frac{d}{dt}(yt^2)}dt=\int{(t^3-t^2+t)}dt$
$y=\frac{t^2}{4}-\frac{t}{3}+\frac{1}{2}+c$
Plug in $t = 1, y = \frac{1}{2}$
$c=\frac{1}{12}$