TITLE: Motivation behind the definition of ideal class group
QUESTION [37 upvotes]: Let $O$ be a Dedekind domain and $K$ its field of fractions. The set of all fractional ideals of $K$ form a group, the ideal group $J_K$ of K. The fractional principal ideals $(a) = aO, a \in K^*$, form a subgroup of the
  group of ideals $J_K$, which will be denoted $P_K$. The quotient group
  $$CL_K=J_K/P_K$$ is called the ideal class group of $K$.

This definition looks completely arbitary, I fail to see why the class group or the ideal class group is worth studying. So, why is the class group or ideal class group interesting? I've read that ideal class group "measures" how much unique factorization fails in a domain, but I don't understand how it does so.
This from Algebraic Number Theory by Neukirch.

The class group $C_K$ measures the expansion that takes place when we pass from numbers to ideals, whereas the unit group $O^*$ measures the contraction in the same process. This immediately raises the problem of understanding these
  groups $O^*$ and $C_K$ more thoroughly.

I don't understand the above paragraph. What does it mean by  "the expansion that takes place when we pass from numbers to ideals"? And why should we even bother about such "expansion"?

REPLY [10 votes]: The concept of ideal entered the world of mathematics somewhere in the 19th century, I believe in the context of the ring of cyclotomic integers $\Bbb Z[\zeta_n]$, where $\zeta_n=e^{2\pi i/n}$, in the attempt to attack Fermat's last theorem.
An ideal is a generalization of a number--or more generally speaking of an element of a ring--because if $x\in{\cal O}_K$ the subset $(x)=x{\cal O}_K$ is indeed an ideal. The concept became soon useful in other contexts, e.g. in geometry where the set of polynomial functions vanishing on an algebraic set in affine space is actually an ideal, and so on.
The motivation behind the introduction of ideals, at least in an arithmetic context, is that a ring of algebraic integers ${\cal O}_K$ is a Unique Factorization Domain (and in particular the notions of irreducible and prime elements coincide) if and only if every ideal $I$ is actually principal, i.e. $I$ is one of those ideal generated by, or "coming from" a single number as before: $I=(x)$.
Actually, a less strict requirement on the ideals of $\Bbb Z[\zeta_p]$ for $p$ prime was devised by Kummer to show the unsolvability, when the requirement is met, of Fermat's equation with exponent $p$.
These are obvious clues that the set of ideals is worth studying.
So, a first natural question is: "How much do we enlarge the set of elements when we generalize from elements to ideals"? Basically, the idea is that the more the set of ideals is relatively bigger, the more "complicated" the arithmetic of ${\cal O}_K$ is. Since both sets are infinite, the answer to this question cannot be too straightforward.
The key observation is that the ordinary multiplication in $K$ induces a multiplication between ideals which in fact "extends" the obvious multiplication $(x)\cdot(y)=(xy)$ between principal ideals. It is remarkable that under this extended multiplication the uniqueness of factorization is recovered: ideals can be uniquely decomposed as  aproduct of prime ideals, and a prime principal ideals are exactly those generated by prime elements. Moreover, if we further generalize our picture introducing fractional ideals, these multiplications actually define a structure of abelian group on the set $J_K$ of fractional ideals for which the subset $P_K$ of principal fractional ideals is a subgroup. 
But now that we have groups there's a very natural way to compare sizes: just take the quotient $C_K=J_K/{\cal O}_K$.
So the fundamental result that $C_K$ is finite means that when we generalize from elements to ideals we do deal with a bigger set, but not that relatively bigger. Or, in other words, that for a generic number field $K$ the arithmetic of ${\cal O}_K$ may be essentially more complicated than that of $\Bbb Z$ but after all not that more complicated (warning: this last interpretation may be read too optimistically and lead to false expectations; :-) )