8. Given the sequence $\left\{a_{n}\right\}$ satisfies
$$
\begin{array}{l}
a_{1}=2, a_{2}=1, \\
a_{n+2}=\frac{n(n+1) a_{n+1}+n^{2} a_{n}+5}{n+2}-2\left(n \in \mathbf{N}_{+}\right) .
\end{array}
$$

Then the general term formula of $\left\{a_{n}\right\}$ is $a_{n}=$
8. $\frac{(n-1)!+1}{n}$.

Let $b_{n}=n a_{n}$. Then
$$
\begin{array}{l}
b_{1}=b_{2}=2, \\
b_{n+2}=n b_{n+1}+n b_{n}-2 n+1 .
\end{array}
$$

Let $c_{n}=b_{n}-1$. Thus,
$$
c_{1}=c_{2}=1, c_{n+2}=n c_{n+1}+n c_{n} \text {. }
$$

Then $c_{n+1}-n c_{n}=-\left[c_{n}-(n-1) c_{n-1}\right]$
$$
=(-1)^{n-1}\left(c_{2}-c_{1}\right)=0 \text {. }
$$

Hence $c_{n}=(n-1) c_{n-1}$
$$
\begin{array}{l}
=(n-1)(n-2) c_{n-2} \\
=\cdots \\
=(n-1)(n-2) \cdots \cdots 1 \cdot c_{1} \\
=(n-1)!.
\end{array}
$$

Therefore, $a_{n}=\frac{(n-1)!+1}{n}$.