What is mathematical difference between "random" and "unique"? Once in a while when a question like "how I get good random numbers" is asked the suggested approach is to just generate an UUID. UUID looks like a random number and it is designed in such way that UUIDs likely never repeat - it is unique.

What is mathematical difference between "unique" and "random"? Why exactly should UUID not be used as a random number - for example as a cryptographic key?
When you say random numbers you want to have a series of numbers such that given any sequence of $i-1$ numbers, the probability of the $i$th number having a certain value is independent from all its predecessors (I (over)simplify here), i.e.

$\begin{equation*}Pr[n_i = k \mid n_0, \dots, n_{i-1}] = Pr[n_i = k]\end{equation*}$

Unique numbers can be generated without having to guarantee that (e.g. just counting upwards yields unique numbers). These kinds of unique numbers can be guessed, which make them bad random numbers.

In fact, most things that are called random-number generators in practice are pseudo-random-number generators. That means that they have a perfectly deterministic and predictable algorithm of constructing the next number but they start with a secret seed that changes from application to application. Without knowing that seed the generated series have many properties of true random sequences. That can be checked by certain statistical methods.

In most practical, every-day scenarios you want to have unguessable sequences, e.g. for password creation. Pseudo-random-number generators are fine for that provided you choose a proper seed; many people use the system timestamp when the request comes in, assuming this is pretty hard to predict up to the millisecond. If you really need the statistical properties of random sequences, for example for Monte Carlo simulations, you should be more wary.

Edit: To clarify: Random sequences (R) and unique sequences (U) are not opposing concepts; you can have all combinations of both:


R, !U: roll die (or observe other allegedly random event, see random.org)
R, U: roll a die with lots of sides and reject duplicates ( or roll many dice)
!R, U: use any bijective enumeration scheme, e.g. $f(n) = n$
!R, !U: $1,1,1,\dots$ (also: PRNG)