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?
Hartshorne says that cohomology was first introduced to abstract algebraic geometry by Serre in his Faisceaux Algebriques Coherents paper (translated to English by a friend of mine). The FAC says
So, it seems that the motivating reason was the general success of homological methods in various branches of algebra, topology and complex geometry.
For a specific problem that asked for proper cohomology theory, read a discussion on Weil conjectures in Hartshorne's "Algebraic Geometry".