The answer to your question is simple. Choose a generator $\sigma$ of $G$. Then we have an exact sequence $$0 \to \mathbb{Z} \xrightarrow{m \mapsto m 1_G} \mathbb{Z}[G] \xrightarrow{\sigma-1} \mathbb{Z}[G] \xrightarrow{g \in G \mapsto 1} \mathbb{Z} \to 0.$$ Since $\mathbb{Z}[G]$ is a free (hence projective) $\mathbb{Z}[G]$ module, this means that we have isomorphisms $\mathrm{Ext}^n(\mathbb{Z},M) \cong \mathrm{Ext}^{n+1}(\mathrm{Im}(\sigma-1),M) \cong \mathrm{Ext}^{n+2}(\mathbb{Z},M)$ for $n \ge 1$, and since $\mathrm{Ext}(\mathbb{Z},M) \cong H^n(M)$, this gives us the desired periodicity.
This is related to the bar resolution in the sense that the bar resolution gives us group cohomology specifically because $\mathrm{Ext}^n(\mathbb{Z},M) \cong H^n(G,M)$. It follows that $\mathrm{Ext}$ can be computed by applying $\mathrm{Hom}(-,M)$ to a projective resolution of $\mathbb{Z}$, and the bar resolution is precisely such a resolution.
Note that by $\mathrm{Ext}$ we mean over the category $\mathbb{Z}[G]$-Mod.