If $G$ is compact, the inclusion $H(M^G) \to H(M)^G$ is an isomorphism. The inverse map is defined as follows: Take a class $\omega$ in $H(M)^G$ and lift it to a closed form $\alpha \in \Omega(M)$. Put $\beta = \int_{g \in G} g^{\ast} \alpha$, where the integral is with respect to Haar measure normalized to have volume $1$. Clearly, $\beta \in \Omega(M)^G$. Our lift will map $\omega$ to $[\beta]$. We must check that $\beta$ is closed, is a de Rham representative of $\omega$, and that its class in $H(M^G)$ is independent of the choice of $\alpha$. Since all $g^{\ast} \alpha$ are closed, so is $\beta$. Since all $g^{\ast} \alpha$ are de Rham representatives of $\omega$, so is $\beta$. Finally, let $\alpha' = \alpha + d \eta$ be another lift of $\omega$. Then $$\int_{g \in G} g^{\ast} \alpha' = \int_{g \in G} g^{\ast} \alpha + d \int_{g \in G} g^{\ast} \eta$$ and $\int_{g \in G} g^{\ast} \eta$ is in $\Omega(M)^G$. When $G$ is not compact, both injectivity and surjectivity can fail. <b>Failure of injectivity</b>: Consider $M = \mathbb{R}$ and $G = \mathbb{Z}$ acting by translations. The $1$-form $dx$ is closed and $G$-invariant on $\mathbb{R}$, but has no $G$-invariant integral. So it gives a nonzero class in $H^1(M^G)$, but of course $H^1(M)^G \subseteq H^1(M) = 0$. <b>Failure of surjectivity</b> Let $M = S^1$. For $\theta \in \mathbb{R}$, define $$\tilde{\phi}(\theta) = \theta + \tfrac{1}{2} \sin \theta.$$ Then $\tilde{\phi}: \mathbb{R} \to \mathbb{R}$ descends to a diffeomorphism $\phi: S^1 \to S^1$, with repelling and attracting fixed points at $\theta = 0$ and $\theta = \pi$ respectively. We let $G = \mathbb{Z}$, acting by $\phi$. The map $\phi$ acts trivially on $H^1(S^1)$. I claim that there is no nonzero smooth $\phi$-invariant $1$-form on $S^1$. Suppose for the sake of contradiction that $\omega$ is a $\phi$ invariant $1$-form. Let $\omega = g(\theta) d \theta$ by $\phi$ invariant, and suppose for the sake of contradiction that $g(\theta_0) \neq 0$ for some $\theta_0 \not \in \pi \mathbb{Z}$. Then $$g(\phi^n(\theta_0)) = \prod_{k=0}^{n-1} (\phi')(\phi^k(\theta_0))^{-1} g(\theta_0).$$ As $k \to \infty$, $\phi^k(\theta_0) \to \pi$ and $\phi'(\phi^k(\theta_0))^{-1} \to 2$. So $g(\phi^n(\theta_0)) \to \infty$ as $n \to \infty$, contradicting that $g(\theta) d \theta$ is supposed to be a continuous $1$-form. <b>A perhaps nicer failure of surjectivity</b> Take a look at this [great post by Robert Bryant][1]. Let $T$ be the torus $S^1 \times S^1$. Let $C_0$ and $C_{\pi}$ be the circles $\{ 0 \} \times S^1$ and $\{ \pi \} \times S^1$. Bryant constructs a flow (in other words, action of $\mathbb{R}$) which takes $C_0$ and $C_1$ to themselves, and where every other orbit approaches $C_0$ as $t \to (-\infty)$, and $C_1$ as $t \to \infty$, with <b>opposite orientations</b>. A picture is worth a thousand words: [Here][2] is what the orbits of this flow looks like on one of the two cylinders of $T \setminus (C_0 \cup C_1)$. I claim that there is no flow invariant $1$-form with $\int_{C_0} \omega \neq 0$. Let $f(t)$ be one of these nonclosed flows. For $T$ very positive, $f$ takes the interval $(T, T + 2 \pi)$ very close to $C_1$ and, for $T$ very negative, it is very close to $C_0$ with opposite orientation. So, if $\omega$ is a flow invariant continuous $1$-form, then $$\int_{C_0} \omega = \lim_{T \to - \infty} \int_T^{T+2 \pi} f^{\ast} \omega = \lim_{T \to \infty} \int_T^{T+2 \pi} f^{\ast} \omega = - \int_{C_1} \omega.$$ On the other hand, $C_0$ and $C_{1}$ are homologous so, if $\omega$ is closed, we have $$\int_{C_0} \omega = \int_{C_1} \omega.$$ Combining these, any closed flow-invariant $1$-form has $\int_{C_0} \omega=\int_{C_1} \omega=0$. <b>One more and I'll shut up</b> Let $C$ be the cylinder $\mathbb{R}^2/\mathbb{Z}$, where we identify $(x,y)$ and $(x+k,y)$ for $k \in \mathbb{Z}$. Let the action of $\mathbb{Z}$ on $C$ be generated by $\phi(x,y) = (x,x+y)$. Let $\gamma$ be the image in $C$ of the line segment $(0,0)$ to $(0,1)$ in $\mathbb{R}^2$. Then $\phi(\gamma)$ is the image of the line segment from $(0,0)$ to $(1,1)$. So, if $\omega$ is a $\phi$-invariant $1$-form, then $\int_{\gamma} \omega = \int_{\phi(\gamma)} \omega$. But $\gamma - \phi(\gamma)$ is a $1$-cycle representing the nontrical class in $H_1(C)$, so we deduce that any $\phi$ invariant $1$-form integrates to $0$ against this class. [1]: https://mathoverflow.net/a/273689/297 [2]: https://en.wikipedia.org/wiki/Reeb_foliation#/media/File:Reebfoliation-ring-2d-2.svg