For some time I've been trying to find an answer to the question "why do we care about or compute sheaf cohomology". As far as I can tell books like Hartshorne treat this as something we already want to compute and do not motivate it. Some posts I've seen talk about how cohomology measures obstructions for glueing local data into global data.
However, they do not explain how this works. For example if I have an affine cover of a scheme and some local data. How do the cohomology groups inform me if I can glue this data together to get global data. I don't even know how to phrase this problem in terms of cohomology.
If you could be as explicit as possible perhaps even giving some examples that would be greatly appreciated.