As a preliminary remark, note that the Tate-Shafarevich group also measures a certain defect, just like the class group. Its elements correspond to homogeneous spaces that have points everywhere locally but no global points. This is explained e.g. in Silverman.
First, let us agree that the Birch and Swinnerton-Dyer conjecture is the elliptic curves analogue of (the square of!) the analytic class number formula. Just like the latter, the former gives an algebraic interpretation of the central value of the $L$-function associated with a Galois representation (in fact a compatible family of $l$-adic Galois representations). See this MO post for more on the comparison of these two formulae.
In both formulae, a central role is played by a certain finitely generated abelian group. In the class number formula, it's the unit group of the ring of integers, in the BSD formula it's the Mordell-Weil group. Both formulae contain the size of the torsion subgroup in the denominator, and the volume (to be precise the covolume under a suitable map) in the numerator. Also, both contain some Tamagawa numbers. In the class number formula, we can only see the Tamagawa numbers at the infinite places, in the guise of some powers of 2 and $\pi$. Finally, both contain the discriminants of the number fields involved. The only other ingredient is the class number in the one case and the size of sha in the other. It is therefore natural to conclude that these "correspond to each other" in these two situations.
There is in fact a more precise correspondence, but one that is much harder to explain. Both formulae have a common generalisation, the Bloch-Kato conjecture. Under this generalisation, sha and the class number literally become the same object attached to a motive. In particular, the class number can, just like sha, be expressed in terms of Galois cohomology. This is explained in some surveys on the Bloch-Kato conjecture and on its equivariant refinement, but even the surveys have quite a lot of prerequisites in order to be able to read and to understand them.
Let $K$ be an algebraic number field and $\mathcal{O}_K$ the integral closure of $\Bbb{Z}$ in $K$. Let us recall that a Dedekind domain is a UFD iff it is a PID. Classically, I think that the questions concerning whether or not a certain Dedekind domain was a UFD were very important, see e.g. this thread here.
Perhaps from the point of view of algebra asking if something is a PID is easier to approach: we know how to factor ideals in Dedekind domains and thus there should at least be a tool to measure how far does a Dedekind domain differ from being a principal ideal domain.
Let me now give you an alternative definition of the ideal class group. We will put an equivalence relation on the set of all ideals defined as follows. We say that an ideal $I$ of $\mathcal{O}_K$ is equivalent to $J$ iff there is $\alpha,\beta \in \mathcal{O}_K$ so that
$$\alpha I = \beta J.$$
One easily checks that this is an equivalence relation. With a little bit more work, one can show that the set of all equivalence classes has a well defined multiplication law and is actually a group. The identity element being the class of all principal ideals. Now for some exercises.
Exercise 1: Check that the "class" of all principal ideals is actually a class. Namely if $I$ is an ideal such that $\alpha I = (\beta)$ then show that $I$ is actually principal. Hint: $\mathcal{O}_K$ is an integral domain.
Exercise 2: Show that this definition of an ideal class group is actually equivalent to the one given in Neukirch. Hint: Use the first isomorphism theorem.
Now do you see how the definition I have given you of an ideal class group actually measures nicely whether or not $\mathcal{O}_K$ is a PID? We see that $\mathcal{O}_K$ is a PID iff its ideal class group is trivial.
Now on to more interesting material. In advanced subjects such as Class Field Theory one can construct something know as the Hilbert Class Field of $K$. I don't know all the details of this construction as my algebraic number theory is not so advanced, but in the Hilbert class field every ideal of $\mathcal{O}_K$ becomes principal!! One can now ask the question: can we avoid talking of the Hilbert class field and find such an extension?
The answer is: Of course we can! This is where the ideal class group comes in. Firstly from Minkowski's bound we get that $Cl_K$ is actually a finite group. Using this, here are now two exercises which you can do:
Exercise 3: Let $I$ be an ideal of $\mathcal{O}_K$ show that there is a finite extension $L/K$ so that $I\mathcal{O}_L$ is principal. Hint: By finiteness of the class group there is an $n$ so that $I^n = \alpha$ for some $\alpha \in \mathcal{O}_K$. Now consider $L = K(\sqrt[n]{\alpha})$.
Exercise 4: Show that there is a finite extension of $L$ in which every ideal of $\mathcal{O}_K$ becomes principal. Wowowowowow!
Hint: Use exercise 3 and the definition of the ideal class group given in the beginning of my answer, not the one in Neukirch.
If you are stuck with any of these exercises I can post their solutions for you to view here.
Solution to Exercise 1 (As requested by user Andrew):
Suppose that $\alpha I = (\beta)$. Then in particular there is $x \in I$ so that $\alpha x = \beta$. We claim that $I = (x)$. Now it is clear that $(x) \subseteq I$. For the reverse inclusion take any $y \in I$. Then $\alpha y = \beta \gamma$ for some $\gamma \in R$. Since $\beta = \alpha x$ we get that
$$\alpha y = \alpha x \gamma.$$
But now $\mathcal{O}_K$ is an integral domain and so $y = x\gamma$, so that $I \subseteq (x)$. Hence $I = (x)$ and so $I$ is principal.
Best Answer
There are various ways to interpret how class groups measure (non)unique factorization. For example, Carlitz (1960) showed that the class group has order at most $2$ iff all factorizations of a nonzero nonunit into irreducibles have the same number of factors. Narkiewicz posed the problem of generalizing this, i.e. devising arithmetical characterizations of class groups. Following is one such characterization, due to J. Kaczorowski, Colloq. Math. 48 (1984), no. 2, 265-267.
Let $\,\cal O\,$ denotes the ring of integers of an algebraic number field. An algebraic integer $\rm\,a\in \cal O\,$ is said to be completely irreducible if it is irreducible and $\rm\,a^n\,$ has a unique factorization for all $\rm\,n\in \Bbb N.\,$ Let $\rm\ {\rm ord}\, a\ $ be the least $\rm\,n\in \Bbb N\,$ such that the length of any factorization of $\rm\,ab\,$ is $\rm\,\le n\,$ for any completely irreducible $\rm\,b\in \cal O.\:$ A sequence of nonassociate algebraic integers $\rm\,a_1,\ldots, a_k\,$ is said to be good if each $\rm\,a_i\,$ is completely irreducible but not prime, and their product $\rm\, a_1\cdots a_k\,$ factors uniquely. Suppose that $\rm\,a_1,\ldots,a_k\,$ is a good sequence having maximal $\rm\,\prod {\rm ord}\,a_i.\,$ Then $\cal O$ has class group $\,\rm\cong C({\rm ord}\, a_1\!) \oplus \cdots \oplus C({\rm ord}\,a_k\!),\:$ where $\rm \,C(n) \cong $ cyclic group of order $\rm\,n.\,$ A proof can be found in Chapter $9$ of Narkiewicz's book Elementary and Analytic Theory of Algebraic Numbers.
Similar results were also published by F. Halter-Koch, and D.E. Rush around the same time. Since then these results have been generalized and abstracted into a powerful theory of nonunique factorization in Krull monoids. Search on said authors and Geroldinger to learn more.
Below is Geroldinger's summary of this line of research, from a paper in Jnl. Algebra 1990