Why is de Rham cohomology important in fundamental physics? I'm currently working on some mathematical aspects of higher-spin gravity theories and de Rham cohomology pops up quite often.
I understand its meaning as the group of closed forms on some space, modulo the exact forms.
Before diving into concrete mathematical details, I was wondering if anyone could explain to me the essence of de Rham cohomology and why does it pop up all over (fundamental) mathematical physics.
If I'm not mistaken, it's a valuable tool because it encodes global topological properties of some space in an algebraic object, which should be easier to work with, right? Where would one struggle without it?
 A: Perhaps the simplest reason de Rham cohomology appears in physics is that in Lagrangian mechanics we care about functionals which usually involve integrating a Lagrangian density. So, something like this:
$$ S[\phi] = \int dx^1 \wedge \cdots \wedge dx^n L(\phi(x),\partial_\mu\phi(x),\dots)$$
where $x = (x^1,\dots,x^n)$. We should think of this integral as a machine that takes in a differential form $dx^1\wedge\cdots\wedge dx^n L$ and spits out a number. However, if we require that $L$ decays sufficiently fast, or that it outright vanishes if $|x|$ is large enough, then we see that the integral of a surface term vanishes:
$$\int dx^1\wedge\cdots\wedge dx^n \partial_\mu V^\mu(x) = 0.$$
This tells us that we should ignore fields which can be written as $\partial_\mu V^\mu(x)$ since adding these sorts of fields does not change the action, and so they cannot influence the Euler-Lagrange equations.
In terms of differential forms, a surface term $dx^1\wedge\cdots\wedge dx^n\partial_\mu V^\mu(x)$ is just an exact form, since
$$d\left(\sum_{\mu = 1}^n (-1)^{n-\mu+1}dx^1\wedge\cdots\wedge dx^{\mu-1}\wedge dx^{\mu + 1}\wedge\cdots\wedge dx^n V^\mu(x) \right) = dx^1\wedge\cdots\wedge dx^n\partial_\mu V^\mu(x).$$
So, we are really interested, not in all $n$-forms (Lagrangian densities), but only $n$-forms modulo exact $n$-forms. Since every $n$-form on an $n$ dimensional space is closed, this means we are interested in the $n$-th de Rham cohomology.
In general, de Rham cohomology appears in many places where functionals defined via integration are present. For instance, you may want to integrate differential forms over a lower dimensional subspace. The process of integrating an arbitrary differential form over a subspace will depend on the choice of subspace (i.e. if you move the subspace a little, all your integrals will change). However, if you restrict yourself to only integrating closed differential forms, then the integrals won't change if the subspace is perturbed slightly. Moreover, in some situations (depending on boundary conditions) exact differential forms will by default integrate to 0. This leaves you interested in closed forms modulo exact forms again. 
As other answers have already mentioned, the results of these integrals can tell you topological information about your space (or subspace, or even some additional structure attached to your space, like a vector bundle). For instance, in Yang Mills theory on $\mathbb{R}^4$, the possible decay conditions for the vector potential $A$ are determined, up to deformations, by a higher-dimensional analogue of the winding number (see https://en.wikipedia.org/wiki/Chern_class#Chern_numbers). The Yang Mills action is defined via an integral of certain differential forms, and its local minima are (up to some universal constants) the winding numbers of the boundary conditions the extremizing potentials satisfy. 
A: You could resumé the importance of cohomology (not only de Rham's) in Physics (and all areas of Applied Mathematics) in a very concise way: if your closed forms are not exact, then cohomology matters. Also, equivalence classes of forms arise in Physics very naturally.
Let's see some examples. 
Take two $n$-forms $A_1$ and $A_2$ and a $(n-1)$-form $B$. If $A_1 = A_2 + dB$, then you can identify $A_1,\,A_2 \in [A]$, that is, both $A_1$ and $A_2$ are members of a certain cohomology class $[A]$. Then you immediately see some objects in Physics can be formulated using cohomology theory:
Example 1: Canonical transformations are elements of the same cohomology class. This can be seen by remembering that $f$ is a canonical transformation if it leaves the canonical 2-form invariant:
$$f^*\omega = \omega \Rightarrow d(x \circ f) \wedge d(y \circ f) = dx \wedge dy \Rightarrow (x \circ f) d(y \circ f) = x \, dy + dS(y,y\circ f) \, ,$$
that is, $ A_1 = A_2 + dB$, where $A_1 = (x \circ f) d(y \circ f)$, $A_2 = x \, dy$ and $B = S(y,y\circ f)$, the generating function of type 4.
Example 2: The potential $A$, from which Maxwell's tensor $F$ is build using $F = dA$, is a 1-form. But we can see that changing $A = A + dB$ does not change $F=dA$, since $d(dA)=0$. This means that Maxwell's equations are invariant if you substitute potentials such that $A_1 = A_2$ in the same cohomology class. This invariance is called gauge invariance.
These are just very straightforward situations where cohomology classes appear, and since cohomology theory is the study of those classes, then it is worth studying a little bit of it in those contexts. If your phase space is complicated, then studying the cohomology of your forms might be easier than looking for conclusions that could be extracted from analysing your equations of motion. Studying cohomology is justifiable mostly because cohomology groups are differential invariants, and in Physics we are (like in the situations I've described in the examples), many times, dealing with diffeomorphisms. 
Edit: This is not supposed to be a real answer, just a sketch on some trivial situations where I ran into cohomology while studying Physics. I hope someone that really works with hard cohomology can answer you better.
A: 
Before diving into concrete mathematical details, I was wondering if anyone could explain to me the essence of de Rham cohomolohy and why does it pop up all over (fundamental) mathematical physics.

Please regard   this as simply a (probably misguided)  attempt at an answer, because I wanted to learn a little bit more myself about the use of forms.
More information can be found at Wikipedia De Rahm Cohomology .
An analogy regarding the essence of De Rahm cohomology. 
Assume there is an electron, hidden somewhere in  space.  You can find it only by using integrals that are based around physical, measurable   properties of the object. So which integrals would be of use?
It's an electron, so using surface integrals along with Guass's law and you  find a value for the electric flux. Then you can repeat this process until you get a non zero answer. This allows you to narrow the search to a given spherical shaped region of space.  You narrow it down by incrementally reducing the size of the sphere.
The point of all this is to try to demonstrate the usefulness of de Rham cohomology as  a general procedure for finding objects in a space that possess a given type of field. The field describes differential forms. You assume  that the field is  strong enough, and   that its strength goes to infinity as you get closer to the object, so that it causes a defect in space. You want to locate this defect, by computing certain integrals and checking that they are not zero. Looking at whether this form integrates to zero or not on various hypersurfaces of the appropriate dimension corresponds to figuring out what the differential form looks like in de Rham cohomology.
Another Intuitive Approach
Homology and cohomology are, amongst other things, a way  of counting the number of holes in a  manifold. 
Assume  a 2-D plane with a point missing out of it. Now, if you have any two points anywhere, given the definition of topology, you can squash  them together into one "bigger" point. Then just go around and avoid the missing point. However, if you have a string looped around the missing point, you can't squish that loop to a point. You end up with a  1-dimensional hole.
Or, for another example, consider a torus. There are some one-dimensional, string loops on the torus you can bring to a point (aka  "null-homotopic closed paths"), but there are some you can't. For instance, any one of these loops cannot be brought to a point:

Not alone are you unable to bring these loops together, you can't even deform the red one to become the purple one. Those are two distinct 1-dimensional holes in our space/manifold, so the 1-D homology (or cohomology) is going to have two independent generators in this situation. 
Any  shape inside the  space is a hole if it has no boundary or it is not the boundary of anything else.
This  stresses the difference  between  closed loops and   open paths; it also says that a closed loop is not a hole if it bounds a patch. A surface with a  boundary is not thought being a hole, but a surface without boundary (like a sphere) is, and it's a hole unless it has a full sphere inside  it.
Forms
0-forms are just functions $f(x,y,z)$
1-forms are like $fdx+gdy+hdz$
2-forms are like $fdxdy+gdxdz+hdydz$
Forms can be differentiated and  integrated. Differentiating a 0-form gives a 1-form, a 1-form gives a 2-form, and so on.
In physics, these options are equivalent to "grad", "div" and "curl". 
A form is closed if its derivative is 0, and a form is exact if it is the derivative of something else. This should be seen as analogous to the two parts of "being a hole" dealt with above: being closed is like "having no boundary", and being exact is like "bounding a patch". A hole is a closed form which is not exact. 

If I'm not mistaken, it's a valuable tool because it encodes global topological properties of some space in an algebraic object, which should be easier to work with, right? Where would one struggle without it?

Speaking in  physical terms, finding a form whose derivative is a given form is like finding a "potential". It is found  by integration, and it is vital that  you can define those integrals in a unique way, completely  independent of the path of integration. This is the main reason  why the differential structure is an alternative way of viewing the geometric structure of paths and holes. 
This is a summary of De Rahm Cohomology.
