Index of a family of operators In the usual setting of the Atiyah-Singer index theorem the situation is as follows: we have a closed smooth manifold $M$ without boundary and $D$ is some elliptic differential operator acting on sections of some vector bundle over $M$. In this situation $D$ turns out to be Fredholm and one can compute its index which is an integer. However I read that AS index theorem has various generalisations: one of them is about a whole family $(D_x)_{x \in X}$ of elliptic operators parametrized by some topological space. I read that in such a situation one can define the index of this family as an element of $K^0(X)$. 

Why the index of such a family is not just an integer valued function? Why it is defined as an element of $K$-theory? 

 A: The space of Fredholm operators classifies $K$-theory. Thus, any continuous family of elliptic operators $(D_x)_{x\in X}$ canonically defines an element in the Abelian group $K(X)$. When $X$ consists of a single point $x_0$, then one can canonically identify $K(\{x_0\})$ with the group of integers.
A: This is just an addendum to Sebastian Goette's excellent answer:
In fact, you can retrieve the integer-valued function that you mention from the $K$-theory class: Let $\iota_x \colon \{pt\} \to X$ be the inclusion that sends $pt$ to $x \in X$. Let $ind(D) \in K^0(X)$ be the $K$-theory class representing the family index of $(D_x)_{x \in X}$. The function you mention will be 
$$
X \to K^0(pt) \cong \mathbb{Z} \quad ; \quad 
x \mapsto \iota_x^*(ind(D))
$$
But this loses a lot of information. In fact, it will just recover the virtual dimension of the fiber over $x$ of the vector bundle Sebastian Goette is talking about in his answer. The index class $ind(D) \in K^0(X)$ also contains global information about "how non-trivial" the vector bundle is. The $K$-theory class $ind(D) \in K^0(X)$ is not a bug, it is a feature! 
A: You can actually see the family index as an element of $K^0(X)$.
First, assume that $\ker(D_x)_{x\in X}$ has constant dimension.
Then it defines a vector bundle over $X$. Because the Fredholm index of $D_x$ is constant, the cokernel also defines a vector bundle. And $\mathrm{ind}(D)=[\ker(D_x)]-[\mathrm{coker}(D_x)]$ is an honest element of $K^0(X)$.
If $\ker(D_x)$ does not have constant dimension, assume that $X$ is compact.
Then the dimension of $\mathrm{coker}(D_x)$ is bounded. Moreover, for some large $N$, the span of $N$ sections of the range of $D_x$ suffice to exhaust $\mathrm{coker}(D_x)$.
 Add $\mathbb C^N$ to the domain of all $D_x$ and map it to the range in such a way that the cokernel is killed. Let $\tilde D_x$ be the new family and put $\mathrm{ind}(D)=[\ker(\tilde D_x)]-N\in K^0(X)$.
If $X$ is noncompact, you need a sufficiently nice description of $K$-theory to extend this method.
One can check that this construction is independent of the modifications you choose. Usually, one assumes more generally that one has a proper submersion $E\to X$ with closed fibre $M$. Your situation is a special case. See Lawson-Michelsohn or Berline-Getzler-Vergne for more explanations and a proof.
