Given a topological space $X$, sheaf cohomology 'measures' the lack of exactness of the global section functor $\Gamma(X, -) : \textbf{Sh}(X) \to \textbf{Ab}$.
From another viewpoint, sheaf cohomology should be measuring the 'obstruction to lifting local to global data'.
I understand the notion of a sheaf as a local assignment to a topological space of algebraic structures that compatibly 'restrict' and 'glue'; and the global sections functor that maps $\mathcal{F} \mapsto \mathcal{F}(X)$.
Yet, I don't understand the connection between the exactness of $\Gamma(X, -)$ and the capability to 'lift local data to global'.
How do these two viewpoints connect?
Best Answer
Well of course a sheaf is by definition something that can lift local datas to global ones in the following sense : if $\{U_i\}$ forms a cover of $X$ and if $f_i\in \mathcal{F}(U_i)$ are sections such that $f_i=f_j\in\mathcal{F}(U_i\cap U_j)$ then the $f_i$'s glue together to form a section $f\in\mathcal{F}(X)$ such that $f|_{U_i}=f_i$.
So what might ask what do not glue inside a sheaf ?
Consider a sheaf $\mathcal{F}$ and sections $f_i\in\mathcal{F}(U_i)$ over a cover of $X$, but this time you don't ask for the $f_i$'s to agree on the intersection. Instead you ask for the $f_i$'s to agree up to a given subsheaf. More precisely, let $\mathcal{G}\subset\mathcal{F}$ be a subsheaf and assume that $f_i-f_j\in\mathcal{G}(U_i\cap U_j)$. Does the $f_i$'s "glue" to a section $f\in\mathcal{F}$ ? I put some quotation marks because, of course you can't expect to find $f$ such that $f|_{U_i}=f_i$ (this would implies that $f_i=f_j$). But you can hope to find $f$ such that $f|_{U_i}-f_i\in\mathcal{G}(U_i)$.
(I believe that this problem was first ask by Cousin with the so-called Cousin's problem : assume you have meromorphic functions $f_i$ defined on $U_i$ such that $f_i-f_j$ are holomorphic. Is there a meromorphic function $f$ such that $f|_{U_i}-f_i$ are holomorphic ?)
It turns out that the sheaf $\mathcal{G}$, or rather its $H^1$, contains the obstruction to lift the local data $(f_i)$ to the global one $f$. Indeed, note that if $g_{ij}=f_i-f_j\in\mathcal{G}(U_i\cap U_j)$, then $(g_{ij})$ forms a $1$-cocycle and this cocycle is a trivial in cohomology iff you can find the $f$.
So now, what is the connection with $\Gamma$ not being exact ? Start with the $f_i\in\mathcal{F}(U_i)$ as above, well obviously $f_i$ defines a section $\overline{f_i}\in(\mathcal{F/G})(U_i)$, and the $\overline{f_i}$'s do glue in $\mathcal{F/G}$, since $\overline{f_i}-\overline{f_j}=0\in(\mathcal{F/G})(U_i\cap U_j)$. So you have a well defined element $\overline{f}\in \Gamma(X,\mathcal{F/G})$. Now you can find the $f$ as above iff $\overline{f}$ is in the image of $\Gamma(X,\mathcal{F})\to\Gamma(X,\mathcal{F/G})$.
The short exact sequence $0\to\mathcal{G}\to\mathcal{F}\to\mathcal{F/G}\to 0$ gives rise to the exact sequence
$$0\to \Gamma(X,\mathcal{G})\to\Gamma(X,\mathcal{F})\to\Gamma(X,\mathcal{F/G})$$ the non right exactness of $\Gamma$ means that we cannot extends this exact sequence by $0$, instead the derived functor $H^1(X,\mathcal{G})$ appears : $$0\to \Gamma(X,\mathcal{G})\to\Gamma(X,\mathcal{F})\to\Gamma(X,\mathcal{F/G})\to H^1(X,\mathcal{G})$$ And the cocycle $(g_{ij})$ constructed above is exactly the image of $\overline{f}$ under the boundary map $\Gamma(X,\mathcal{F/G})\to H^1(X,\mathcal{G})$. Putting together what we said before we see that the following are equivalent :