Example 4 consists of forming $n$-digit numbers using the digits $1,2,3$, and in this $n$-digit number, each of $1,2,3$ must appear at least once. How many such $n$-digit numbers are there?
Let $U$ be the set of $n$-digit numbers composed of $1, 2, 3$, $A_{1}$ be the set of $n$-digit numbers in $U$ that do not contain the digit 1, $A_{2}$ be the set of $n$-digit numbers in $U$ that do not contain the digit 2, and $A_{3}$ be the set of $n$-digit numbers in $U$ that do not contain the digit 3. Then,
$$
\begin{array}{l}
|U|=3^{n} ;\left|A_{1}\right|=\left|A_{2}\right|=\left|A_{3}\right|=2^{n} ; \\
\left|A_{1} \cap A_{2}\right|=\left|A_{2} \cap A_{3}\right|=\left|A_{3} \cap A_{1}\right|=1 ; \\
\left|A_{1} \cap A_{2} \cap A_{3}\right|=0 . \\
\text { Therefore, }\left|\overline{A_{1} \cup A_{2} \cup A_{3}}\right| \\
=|U|-\left|A_{1}\right|-\left|A_{2}\right|-\left|A_{3}\right|+\left|A_{1} \cap A_{2}\right|+ \\
\quad\left|A_{2} \cap A_{3}\right|+\left|A_{3} \cap A_{1}\right|-\left|A_{1} \cap A_{2} \cap A_{3}\right| \\
=3^{n}-3 \times 2^{n}+3 \times 1-0=3^{n}-3 \times 2^{n}+3 .
\end{array}
$$

Therefore, the number of $n$-digit numbers that meet the criteria is
$$
3^{n}-3 \times 2^{n}+3 \text {. }
$$

Next, let's look at a variant problem involving the application of the principle of inclusion-exclusion.