An intuitive explanation for group cohomology via cochains? I'm fairly new to topology, and so far I've understood cohomology via cochains. 
First we build an object called a cochain ($C^n$), then define a differential map that takes you from $C^n$ to $C^{n+1}$. Then all the types of cohomology groups I've encountered can be easily defined as:
\begin{equation}
H^n(M) = Z^n / B^n
\end{equation}
Where $Z^n$ is the n-cocyle and $B^n$ is the n-coboundary.
The trouble I'm facing is in defining the map $\partial^n: C^n \rightarrow C^{n+1}$
In other cohomologies, the map has an intuitive explanation. For example, in deRham cohomology, the map just sends a differential form to a higher differential form, but due to Stokes' theorem we can interpret the nth form being the boundary of an n+1th form. In simplical homology, we define the map to be the boundary of the n-chain, so a line segment will have the two endpoints as its boundary etc.
In group cohomology however, the map is defined as: $f:G^n \rightarrow A$ where A is a G module, and:
\begin{equation}
\partial^i f(g_0,\cdots,g_i) = g_o f(g_1,\cdots,g_i) + \sum_{j = 1}^i (-1)^j f(g_0,\cdots, g_{j-1} g_{j}, g_{j+1}, \cdots, g_i) + (-1)^{i+1} f(g_0,\cdots, g_{i-1})
\end{equation} 
Now I understand that you can prove the various "standard" properties of this map using this definition (like $\partial^{i+1} \partial^i f = 0 $ etc.), but what is the intuitive explanation for what's going on? Why is this map defined the way it is? How does this correspond to the boundary interpretation of other types of cohomologies? How can I "see" it being a boundary without explicitly computing $\partial^2 = 0$? 
And what happens when the groups are continuous? For lie groups can we apply deRham cohomology? What about cohomology on principal G-bundles? Any introductory resources on this subject would be much appreciated!
 A: See section 3 here https://ncatlab.org/nlab/show/group+cohomology, and read https://en.wikipedia.org/wiki/Nerve_(category_theory). 
A group is thought of as a category with 1 object and morphisms corresponding to the elements of the group (with composition being the group function). The nerve of this category is the simplicial set (for cohomology purposes it's the same as a simplicial complex), and it's simplicial cohomology is what you are looking for.
I imagine you don't know category theory yet, but since the category is very simple you can try to chose a small group and follow the construction by hand until you get the idea (objects=vertices, morphisms=edges for this purpose).
A: Both answers are wonderful, but I have to admit that there's still some gap between my understanding and why modern topologists think of $BG$ in that way.
That being said, you can see why group cocycles/coboudaries are defined in that way by looking at a classical problem, at least for small $n$.
I will lay out a classical problem, and explain how the cocycle/coboundary conditions show up naturally. For my own good, I hope someone will explain how topologists went from this classical problem to the construction of $BG$ (or bar constructions in general).
Anyway, here we start.

Let $K$ and $G$ be two finite groups. You can easily form their trivial product $K\times G$. This is another group, and it helps us to understand group theory a bit more because now we can investigate big groups by breaking them down to smaller ones.
However, not every big group is a trivial product of smaller groups, so following the same thought we want to find more creative products of $K$ and $G$. One easy example all freshmen know is the semi-direct product, provided that $G$ acts on $K$.
It has been successful, so people wondered all possible nontrivial products we can build from $K$ and $G$. This is the so-called group extension problem. More precisely, given two finite groups $K$ and $G$, we want to find all groups $E$, so that $E/K$ is isomorphic to $G$.
It is hard to construct $E$ directly, so let's think in an opposite way. We imagine that we have found such extension $E$. Its group structure is still unknown, but as a set it must be $K\times G$. We will try to describe the group structure of $E$ by looking at the $K\times G$ side. This way has its pros and cons. Pros: it's easier to write things down concretely. Cons: the structure of $E$ might be highly twisted, so writing everything down in terms of $K\times G$ might make things messy.
(Aside: if you have some experience with differential geometry, the way I'm using now is like drawing a map for $E$. $K\times G$, as a map, gives you a convenient coordinate system for you to write things down, but since $E$ is "curved", we need to develop a corresponding calculus on the map side.)
To go between both side, we want to find a good map that sends $K\times G$ to $E$. From $K$ to $E$ is simple, since by assumption (the "imagination" given above) $K$ already sits in $E$. Unfortunately, for the other side, there's no good map from $G$ to $E$ yet. So lets just pick an arbitrary one $s: G\to E$, so that $s$ serves as a section.
(Aside: I would appreciate if someone can draw a short exact sequence that will make things clearer.. I'm terrible at drawing with latex.)
Note that we cannot expect $s$ to be a group homomorphism! In fact, if that's the case we are back to the semi-direct product, and vice versa (exercise). We want to create more creative products, so we really want some section $s$ that is highly distorted (from being a group homomorphism)!
To measure how distorted it is, we introduce a set-theoretic function $f(g_1,g_2)=s(g_1)s(g_2)s(g_1g_2)^{-1}$. Note that $s$ is not distorted if and only if $f$ is trivial. We want $f$ to be as nontrivial as possible.
Now, after the set-theoretic section $s$ has been chosen, we have a set-theoretic bijection (exercise) between our "space" $E$ and out "map" $K\times G$:
$$ K\times G \to E: (k,g)\mapsto k\,s(g). $$
A fun exercise is to write down how this maps tells us the group structure of $E$. The result is:
$$ (k_1,g_1)(k_2,g_2) = (k_1\, ^{s(g_1)}k_2\, f(g_1,g_2), g_1g_2),$$
where $^xk$ means $xkx^{-1}$, which lies in $E$ because $K$ is a normal subgroup of $E$ by assumption (the imagination made above). It should not be surprising that the distortion measure $f$ shows up in our map. Convince yourself!
Another fun exercise is to translate the associativity on the "space" side to the "map" side: this simply gives you
$$^{s(g_1)}f(g_2,g_3)\,f(g_1,g_2g_3)f(g_1g_2,g_3)^{-1}f(g_1,g_2)^{-1} = 1 \in K.$$
Cocycles
If $K$ is abelian, then $f$ is a $2$-cocycle with the action of $G$ on $K$ given by conjugation. This gives a motivation of why cocycles are defined that way.
(Aside: It should not be surprising why such horrible formula show up, since $s$ is chosen arbitrarily as a set-theoretic map!)
(Aside: Exercise -- what does the other group structures of $E$ translate to? I don't know.. )
Conversely, given a left group action $G$ on $K$ and a $2$-cocycle $f\in Z^2(G,K)$, we can construct a space $E$ simply by reversing the process above. Note that in the space $Z^2(G,K)$ includes the action implicitly.
Here is an explicit construction: set $E$ to be $K\times G$ as a set, and define the group operation by
$$(k_1,g_1)(k_2,g_2) = (k_1\,^gk_2\,f(g_1,g_2),g_1g_2).$$
It is an easy exercise to write down the inverses and the identity element in this set.
Conclusion of the first part: Fix a left group action $G$ on $K$. Any $2$-cocycle $f \in Z^2(G,K)$ gives an interesting product of $K$ and $G$! If $f$ is trivial, then the interesting product is the semi-direct product, which is less interesting.
(Remark: to check that $K$ is central.)
Coboundaries
The next question is of course to find redundancy: do any two given $2$-cocycle $f$ and $h$ give "different" products? If not, how do we identify which two give the same product?
Here, by different I mean that they are not the same. Of course they aren't the same set-theoretically, so I should be clearer: two products $E_f=(K\times G)_f$ and $E_h=(K\times G)_h$ are the same if there is a group isomorphism from one to another that respect all given structures.
So let's suppose $E_f$ and $E_g$ are the same, i.e. there is a good isomorphism between them. The image of $(e,g)_f \in E_f$ in $E_h$ under this isomorphism must be in the form $(k_g,g)_h \in E_h$, for some $k_g \in K$ (exercise). Lets denote $k_g$ by $\phi(g)$ -- it is a function in $g$ -- it is a function $\phi:G\to K$!
The last fun exercise is to show that $f/h$ is the coboundary of $phi$ provided that $K$ is abelian, and vice versa! This exercise is even more fun because you have to find a way to write down the image of $(k,g)_f$ in $E_h$. This gives a motivation of why coboudaries are defined that way.
My questions

*

*How did modern topologist come up with the idea of bar construction from this kind of classical problems? It's kinda sad that nowadays it's so hard to bridge the classical themes to modern considerations.. at least for me!


*If we did not assume $K$ to be abelian, we still get something that could be call the nonabelian cocycles/coboudaries, but it is much harder to deal with. How are this done in modern language? And again can you connect the modern treatment of nonabelian cohomology with this classical picture?
A: What I'm going to say is pretty much the same that JK34 has written in their answer, but in a more elementary approach that is hopefully adding some insight. 
Suppose that you want to look at the "shape" of a group $G$. That is, let's construct a space that "looks like $G$". For simplicity suppose that $G$ is finite or finitely presented.
The idea is as follows: draw a point, call it $*$. Now for each element $g$ of $G$, draw a loop based at $*$, that is, a closed path from $*$ to itself. 
The identity is assigned a "trivial" loop, meaning that it doesn't have any extension, it "stays at the base point" (imagine the trivial loop in algebraic topology). 
Given $g\in G$, also $g^{-1}$ is in $G$. Don't add an extra path for $g^{-1}$, just imagine that your loops can be walked either way.
Now, given $g,h\in G$, clearly $gh$ is in $G$ too, so it has its own arrow. However, this arrow should not be independent of $g$ and $h$, it should be somehow the composition. A way to encode this (at least up to homotopy) is to add a 2-simplex (a filled triangle) between those three arrows (can't draw them here, sorry! Imagine a triangle with vertices all equal to $*$ and sides $g$, $h$, and $gh$). Do this for every pair of elements of $G$. 
Now composition in the group is associative, that is, $(gh)i=g(hi)$ for each $g,h,i\in G$. Consider the triangles determined by $(g,h)$, $(gh,i)$, $(g,hi)$ and $(h,i)$. Can you see that these triangle form the faces of a tetrahedron? The first two and last two, pairwise glued, should again in some sense be the same, because of associativity. So, fill this tetrahedron too, with a 3-cell. 
...and so on, imagine an $n$-dimensional simplex every time you have a composition of $n-1$ elements.
The resulting space is going to be a simplicial complex, called the classifying space of $G$, denoted by $BG$ (notation may vary).
Try to prove that

The classifying space of $\Bbb{Z}$ is the circle. 

(Hint: we have one loop for each element of $G$...). If you understand that, it shouldn't come as a surprise that

More generally, the fundamental group of $BG$ is $G$

and (can you see why?),

All higher homotopy groups of $BG$ are trivial.

Now, as we have seen, a 2-simplex (i.e. triangle) in $BG$ is given by a pair $(g,h)$, with $g,h\in G$. What are the faces of that triangle? Those are the sides, which as we have constructed, are $g,h$, and $gh$. So, adding the signs consistently, it makes sense that the boundary of the simplex $(g,h)$ is 
$$
\partial(g,h) = g - gh + h.
$$
This should give you an idea why the coboundary map in group cohomology is defined that way: we have that $(df)(g,h)=f(\partial(g,h))$. 
Can you see what the boundary maps of simplices of degree $3$ will do? And higher?
This should also give you an idea why, in general, 

The singular cohomology of $BG$ is exactly the group cohomology of $G$.

So, in short: group cohomology is helpful to study groups because it studies the "shape of a group" in the sense of algebraic topology.
