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?