$$\int_0^l{\dfrac{2\sin^3\left(\frac{{\pi}x}{l}\right)\sin\left(\frac{{\pi}nx}{l}\right)}{l}dx} = \dfrac{12\sin\left({\pi}n\right)}{{\pi}\left(n^4-10n^2+9\right)}$$
But this function is not defined at $n = 1$ and $n = 3$. Why does this happen even though I integrated it for all $n$. This also clearly has an integral defined if we substitute $n = 1$ before integrating.
link to the steps while integrating. Its an online integral calculator
You are probably trapped by a case similar to
$$I_m=-\int_0^{2\pi}\cos mx\,dx=\left.\frac{\sin mx}m\right|_0^{2\pi}=\frac{\sin2\pi m}m,$$
believing that it is established "for all $m$".
The final expression is indeed undefined for $m=0$ because the integrand degenerates to $1$ and the antiderivative doesn't hold.