Other answers surely are advanced, but it may be a good idea to remind explicitly that classClass number $h(K)$ is exactly the quantitative measure of the failure of unique factorization: by its definition it measures "how many more ideas are there compared to numbers".
That is,To clarify: decomposition is always unique for ideals, so if allthe only ideals you have are numbers (class number = 1that is, $h = 1$), then you don't have any problem decomposing numbers (PIDso, you have PID). FurtherFurthermore, the more "leftover" ideals you have (ideal class group), the more possibilities of writing different decompositions of numbers there areexist.
This vague statement can be turned into some precise ones. If you have different factorizations of number $x$, this means the prime ideals in the decomposition $\mathfrak p_1\mathfrak p_2\dots\mathfrak p_n$$x = \mathfrak p_1\mathfrak p_2\dots\mathfrak p_n$ are grouped in a different way. I think youYou can establish from here that the bound on the number of possible factorizations isdifferent factorizations; may be (not sure here) it can be shown to be no more than $C(h)$, where $h$ is the class number.
Another precise statement that easily folows, already mentioned, istheorem that follows (mentioned by Olivier): $x^h$ must always have a decomposition into true numbers rather then ideals (indeed. Indeed, it is $\mathfrak p_1^h\mathfrak p_2^h\dots\mathfrak p_n^h$)$x^n = \mathfrak p_1^h\mathfrak p_2^h\dots\mathfrak p_n^h$ and you need to use the fact that any element $p$ in abelian group of size $h$ has the property $p^h = 1$.