In lecture, my teacher proved the theorem that given a smooth $G$-action by a compact, connected Lie group on a manifold $M$, the de Rham cohomology of the $G$-invariant differential forms $H^p_G(M)$ is isomorphic to the full de Rham group $H^p(M)$.
Then he proceeded to give some examples. For instance, let $SO(m+1)$ act on $S^m$. Then $H^p(S^m)= 0$ for $0<p<m$ since given $\omega \in \Omega^k(M)$, take $v_1, \dotsc, v_k \in T_qM$ for any $q\in M$. There exists $T\in SO(m+1)$ such that $T$ preserves $v_2, \dotsc, v_k$ and $Tv_1 = -v_1$. So $$(T^*\omega)(v_1, \dotsc, v_k) = \omega(dT(v_1), \dotsc, dT(v_k))\\ = \omega(T(v_1), \dotsc, T(v_k)) = \omega(-v_1, \dotsc, v_k).$$
So if $\omega$ is $G$-invariant, we have $$\omega(v_1, \dotsc, v_k) = T^*(\omega)(v_1, \dotsc, v_k) = \omega(-v_1, \dotsc, v_k)\\ \Longrightarrow \omega=0.$$
Then he brought up the case of $\mathbb{R}P^n$, similarly acted upon by $SO(m+1)$. I didn't quite understand what he was talking about, but he wrote $$H^k(\mathbb{R}P^n)=\begin{cases} \mathbb{R} &k=0 \\ 0 &k>0. \end{cases}$$
I think he is wrong in the top dimension when $n$ is odd, but let's just worry about $0<k<n$. How does the action establish this?
Edit: Now that I've written all this out, it seems we can do it exactly as in the $S^n$ case. Perhaps you can confirm, and make sure there are no errors in my explanation of that case.
This stack question finds the de Rham groups of $\mathbb{R}P^n$ in a different way, using the projection map $S^n \to \mathbb{R}P^n$.
The same construction can be used to calculate $H^k(\mathbb{RP}^n)$ when $n>k$. For $n=k$, and $n$ is even, the same construction works because if we consider $[v]\in \mathbb{RP}^n$, where $v\in \mathbb S^n$, then for all $w\in T_{[v]}\mathbb{RP}^n$, define $A\in SO(n+1)$ by
$$A(v) = -v, A(w) = -w\ \ \text{and }A (y)=y$$
for all other vectors $y$ $\perp$ to $v$ and $w$. Then $A([v]) = [v]$, $A_*(w) = -w$, $A_*(y) = y$. The same argument shows that $H^n(\mathbb{RP}^n)=0$ when $n$ is even.