Why was Sheaf cohomology invented?
Sheaf cohomology was first introduced into algebraic geometry by Serre. He used Čech cohomology to define sheaf cohomology. Grothendieck then later gave a more abstract definition of the right derived functor of the global section functor.
What I still don't understand what was the actual motivation for defining sheaf cohomology. What was the actual problem they were trying to solve?
Solution 1:
Sheaves and sheaf cohomology were invented not by Serre, but by Jean Leray while he was a World War II prisoner in Oflag XVII (Offizierlager=Officer Camp) in Austria.
After the war he published his results in 1945 in the Journal de Liouville.
His remarkable but rather obscure results were clarified by Borel, Henri Cartan, Koszul, Serre and Weil in the late 1940's and early 1950's.
The first spectacular application of Leray's new ideas was Weil's proof of De Rham's theorem: he computed the cohomology of the constant sheaf $\underline {\mathbb R}$ on a manifold $M$ through its resolution by the acyclic complex of differential forms $\Omega_M^*$ on $M$.
The next success story for sheaves and their cohomology was the proof by Cartan and Serre of theorems $A$ and $B$ for Stein manifolds, which solved a whole series of difficult problems (like Cousin I and Cousin II) with the help of techniques and theorems of Oka, who can be said a posteriori to have implicitly introduced sheaves in complex analysis.
The German complex analysts (Behnke, Stein, Thullen,...) who had up to then be the masters of the field were so impressed by the new cohomology techniques that they are reported to have exclaimed: "the French have tanks and we have bows and arrows!"
Armed with his deep knowledge of these weapons of complex analysis Serre took the incredibly bold step of introducing sheaves and their cohomology on algebraic varieties endowed with their Zariski topology.
This was of remarkable audacity because of the coarseness of Zariski topology, which had led specialists to believe that it was just some rather unimpressive tool allowing one for example to talk rigorously of generic properties.
As all algebraic geometers now know, Serre stunned his colleagues by showing in FAC how cohomological methods yielded deep results, at the centre of which are theorems $A$ and $B$ for coherent sheaves on affine varieties.
Other fundamental novelties obtained by Serre in FAC are his twisting sheaves $\mathcal O(n)$, the computation of the cohomology of coherent sheaves on projective space, the vanishing of the cohomology groups $H^q(V,\mathcal F(n))$ on a projective variety $V$ for $q\gt0, n\gt\gt 0$,...
Last not least: the introduction of sheaves and their cohomology in FAC paved the way for Grothendieck's revolutionary introduction of schemes in algebraic geometry, as acknowledged in the preface of EGA.
Actually reading FAC was the secondary thesis of Grothendieck, accompanying his PhD on nuclear spaces in functional analysis.
Afer his PhD defence, someone (Cartan if I remember the anecdote correctly) told him good-humouredly that he seemed not to have understood much in FAC.
The story goes that Grothendieck was piqued, invested much energy in understanding Serre, and the rest is history. Se non è vero, è ben trovato...
Solution 2:
Sheaf cohomology is just the elaboration of the following problem:
you have a space and a covering, and you can do something you want on each set of the covering: can you do it on the whole space?
This occurs in many places, from the Cousin problem in complex analysis to the construction of sections of fiber bundles to the pasting together of solutions of partial differential equations which you can solve locally to many, many other contexts.
In a way, once you are caught in a situation where you want to piece local information to obtain global information, you are more or less doomed to develop sheaf cohomology.