Hint Following what you've done already, integrating by parts with $u = \sin n \theta$, $dv = \cos \theta \,d\theta$ gives
\begin{multline}\color{#df0000}{I_n} = \underbrace{\sin n \theta}_u \, \underbrace{\sin \theta}_v \vert_0^{\pi / 2} - \int_0^{\pi / 2} \underbrace{\sin \theta}_v \, \underbrace{\cos n\theta \, d\theta}_{du} = \sin \frac{\pi n}{2} - n \color{#1f1fff}{J_n}, \\ \color{#1f1fff}{J_n := \int_0^{\pi / 2} \cos n \theta \sin \theta \, d\theta} .\end{multline}
We now apply integration by parts to the integral $\color{#3f3fff}{J_n}$ with $p = \cos n \theta$, $dq = \sin \theta \,d\theta$:
$$\color{#3f3fff}{J_n} = \cos n \theta (-\cos \theta)\vert_0^{\pi / 2} - \int_0^{\pi / 2} \underbrace{-\cos \theta}_q \cdot \underbrace{- n \sin n \theta \,d\theta}_{dp} = 1 - n \color{#df0000}{I_n} .$$
Substituting to eliminate $\color{#3f3fff}{J_n}$ gives $\color{#df0000}{I_n} = \sin \frac{\pi n}{2} - n (1 - n \color{#df0000}{I_n})$, and rearranging to solve for $\color{#df0000}{I_n}$ gives the claimed identity: $$\color{#df0000}{\boxed{I_n = \frac{n - \sin \frac{\pi n}{2}}{n^2 - 1}}} .$$ Notice that for $n \equiv 0, 2 \pmod 4$ this simplifies to $\frac{n}{n^2 - 1}$, for $n \equiv 1 \pmod 4$ to $\frac{1}{n + 1}$, and for $n \equiv 3 \pmod 4$ to $\frac{1}{n - 1}$.