"Trivial" geometry behind the intersection pairing on surfaces The intersection pairing between two divisors on a nonsingular algebraic surface over a field is defined thanks to the following theorem (the reference is Hartshorne's book): 



One can define a pairing for any couple of invertible sheaves $\mathcal L,\mathcal M\in\operatorname{Pic}(X)$ as follows:
$$\mathcal L.\mathcal M:=\chi(\mathcal O_X)-\chi(\mathcal L^{-1})-\mathcal (M^{-1})-\chi( \mathcal L^{-1}\otimes \mathcal M^{-1})\quad\quad (\ast)$$  
By using the well known isomorphism between $\operatorname{Pic}(X)$ and the group of divisors up linear equivalence, one can clearly define:
$$C.D:=\mathcal O_X(C).\mathcal O_X(D)$$
and the final step is to show that this definition satisfies properties (1)-(4) of the above theorem.

So everything is very clear, but I don't understand what is the
  meaning of the definition $(\ast)$. It seems to me that this pairing
  for invertible sheaves appears out of the blue. Can you give any
  intuitive motivation about its nature? Why do we need the Poincare characteristics? Why are we taking the inverse sheaves? 

 A: Here is a simple way to connect ($\star$) to your geometric intuition.
Suppose $C$ and $D$ are two curves on your surface. There exists an exact sequence,
$$ 0 \to \mathcal O_{X}(-C-D) \to \mathcal O_X(-C)\oplus \mathcal O_X(-D) \to O_X \to \mathcal O_{C \cap D} \to 0,$$
where $\mathcal O_{C \cap D}$ is the skyscraper sheaf supported on the intersection points of $C$ and $D$ with stalks of dimension equal to the intersection multiplicity at each intersection point.
[To spell out the above morphisms more explicitly, suppose that ${\rm Spec \ } A \subset X$ is a open affine on which $C$ and $D$ are the vanishing loci of $f$ and $g$ in $A$ respectively. Then the associated exact sequence of modules over ${\rm  Spec \ } A$ is
$$ 0 \to A \overset{(-g,f)}{\to} A^{\oplus 2}\overset{(f,g)}{\to} A \to A/(f,g) \to 0.$$
Indeed, the stalk at an intersection point $x \in C \cap D$ is $A_x/(f,g)$, whose dimension is the standard definition of the intersection multiplicity of $C$ and $D$ at $x$.
]
Anyway, your intuitive notion of intersection pairing is that $C.D$ is the number of points in $C\cap D$ counted with multiplicity. But this is exactly the same thing as the number of global sections of $\mathcal O_{C \cap D}$. Since $\mathcal O_{C \cap D}$ is a skyscraper sheaf, its higher cohomologies vanish, so this is the same as the Euler characteristic $\chi(\mathcal O_{C \cap D})$. But then, by the above exact sequence, this Euler characteristic is equal to $\chi(\mathcal O_X) - \chi(\mathcal O_X(-C)) - \chi(\mathcal O_X(-D)) + \chi(\mathcal O_X(-C-D)),$
which agrees with your $(\star)$.
A: Your questions are a frequent reaction to the "rabbit-out-of-a-hat" type of proof. The reason for doing it that way is a matter of exposition. A more natural approach would be step-by-step. First, for two nonsingular curves $C$ and $D$, meeting transversally, define $C.D$ to the the number of intersection points. Next, keeping $C$ fixed, let's show this depends only on the linear equivalence class of $D$. This is because if $D \sim D'$ on the surface, then $C.D \sim C.D'$ as divisors on $C$. And then we know that linearly equivalent divisors on a curve have the same degree. This will still work if $D$ becomes singular, as long as its intersection with $C$ is a finite set of points.
Maybe you can work out the rest for yourself. If you start with arbitrary divisors, any such is a difference of effective curves, and using Bertini's theorem, you can take them to be nonsingular. This gives a definition for any two divisors, but you have to show it is independent of the choices made. By the time you work this all out in complete detail, perhaps you can appreciate the choice of Hartshorne to take the more efficient "rabbit-out-of-a-hat" method.
Of course Kenny's answer to your question is quite excellent.
