See also this Math.SE post I wrote for some more motivation: http://math.stackexchange.com/a/270266/873. Recall that $\mathrm H^*(G,M)=\mathrm{Ext}^*(\mathbb{Z},M)$.



After learning some more math, I've come across the following example of a use of group cohomology which sheds some light on its geometric meaning. (If you want to see a somewhat more concrete explanation of how group cohomology naturally arises, skip the next paragraph.)

We define an elliptic curve to be $E=\mathbb{C}/L$ for a two-dimensional lattice $L$. Note that the first homology group of this elliptic curve is isomorphic to $L$ precisely because it is a quotient of the universal cover $\mathbb{C}$ by $L$. A theta function is a section of a line bundle on an elliptic curve. Since any line bundle can be lifted to $\mathbb{C}$, the universal cover, and any line bundle over a contractible space is trivial, the line bundle is a quotient of the trivial line bundle over $\mathbb{C}$. We can define a function $j(\omega,z):L \times \mathbb{C} \to \mathbb{C} \setminus \{0\}$. Then we identify $(z,w) \in \mathbb{C}^2$ (i.e. the line bundle over $\mathbb{C}$) with $(z+\omega,j(\omega,z)w)$. For this equivalence relation to give a well-defined bundle over $\mathbb{C}/L$, we need the following: Suppose $\omega_1,\omega_2 \in L$. Then $(z,w)$ is identified with $(z+\omega_1+\omega_2,j(\omega_1+\omega_2,z)w$. But $(z,w)$ is identified with $(z+\omega_1,j(\omega_1,z)w)$, which is identified with $(z+\omega_1+\omega_2,j(\omega_2,z+\omega_1)j(\omega_1,z)w)$. In other words, this forces $j(\omega_1+\omega_2,z) = j(\omega_2,z+\omega_1)j(\omega_1,z)$. This means that, if we view $j$ as a function from $L$ to the set of non-vanishing holomorphic functions $\mathbb{C} \to \mathbb{C}$, with (right) L-action on this set defined by $(\omega f)(z) \mapsto f(z+\omega)$, then $j$ is in fact a $1$-cocyle in the language of group cohomology. Thus $H^1(L,\mathcal{O}(\mathbb{C}))$, where $\mathcal{O}(\mathbb{C})$ denotes the (additive) $L$-module of holomorphic functions on $\mathbb{C}$, classifies line bundles over $\mathbb{C}/L$. What's more is that this set is also classified by the sheaf cohomology $H^1(E,\mathcal{O}(E)^{\times})$ (where $\mathcal{O}(E)$ is the sheaf of holomorphic functions on $E$, and the $\times$ indicates the group of units of the ring of holomorphic functions). That is, we can compute the sheaf cohomology of a space by considering the group cohomology of the action of the homology group on the universal cover! In addition, the $0$th group cohomology (this time of the meromorphic functions, not just the holomorphic ones) is the invariant elements under $L$, i.e. the elliptic functions, and similarly the $0$th sheaf cohomology is the global sections, again the elliptic functions.

More concretely, a theta function is a meromorphic function such that $\theta(z+\omega)=j(\omega,z)\theta(z)$ for all $z \in \mathbb{C}$, $\omega \in L$. (It is easy to see that $\theta$ then gives a well-defined section of the line bundle on $E$ given by $j(\omega,z)$ described above.) Then, note that $\theta(z+\omega_1+\omega_1)=j(\omega_1+\omega_2,z)\theta(z) = j(\omega_2,z+\omega_1)j(\omega_1,z) \theta(z)$, meaning that $j$ must satisfy the cocycle condition! More generally, if $X$ is a contractible Riemann surface, and $\Gamma$ is a group which acts on $X$ under sufficiently nice conditions, consider meromorphic functions $f$ on $X$ such that $f(\gamma z)=j(\gamma,z)f(z)$ for $z \in X$, $\gamma \in \Gamma$, where $j: \Gamma \times X \to \mathbb{C}$ is holomorphic for fixed $\gamma$. Then one can similarly check that for $f$ to be well-defined, $j$ must be a $1$-cocyle in $H^1(\Gamma,\mathcal{O}(X)^\times)$! (I.e. with $\Gamma$ acting by precomposition on $\mathcal{O}(X)^\times$, the group of units of the ring of holomorphic functions on $X$.) Thus *the cocycle condition arises from a very simple and natural definition* (that of a function which transforms according to a function $j$ under the action of a group). A basic example is a modular form such as $G_{2k}(z)$, which satisfies $G_{2k}(\gamma z) = (cz+d)^{2k} G_{2k}(z)$, where $\gamma = \left(\begin{array}{cc} a & b \\ c & d \end{array}\right)  \in SL_2(\mathbb{Z})$ acts as a fractional linear transformation. It follows automatically that something as simple as $(cz+d)^{2k}$ is a cocycle in group cohomology, since $G_{2k}$ is, for example, nonzero.