The Stirling number of the second kind, $\left\{ \begin{array}{c} n\\k \end{array} \right\}$, gives the number of ways to partition the set $A=\{1,2,\cdots,n\}$ into $k$ classes.$^1$
So $$\left\{ \begin{array}{c} n\\2 \end{array} \right\}=\frac{2^n-2}{2}=2^{n-1}-1.$$
We can put each item (an element of $A$) into one of two bins. Since we don't want empty bins, we subtract $2.$ Then, since we don't distinguish between bins, we divide by $2.$
Now we look at $\left\{ \begin{array}{c} n\\n-2 \end{array} \right\}$.
Most of the elements will end up in its own bin. We have two cases: ($1$) three in one bin, or ($2$) there are two bins, each with two elements:
$$\left\{ \begin{array}{c} n\\n-2 \end{array} \right\}=\binom{n}{3}+\frac{1}{2}\binom{n}{2}\binom{n-2}{2}=\binom{n}{3}+3\binom{n}{4}.$$
In both combinatorial expressions, $\binom{n}{3}$ is the number of ways of executing part $(1)$.
For part $(2)$, we could either choose two to be in a bin, then choose two of the remaining $n-2$. Because we could pick the two pairs in either order, we divide by two.
Alternatively (as expressed in the last sum) we can choose the four which gives $\binom{n}{4}$, then we take any of the four and choose the other one of the remaining three to go in the same bin: $\binom{3}{1}=3$.
$^1$Wilf, H. S., $\textbf{generatingfunctionology}$, 3rd edition, CRC Press, p. 18.
https://math.stackexchange.com/questions/4186803/stirling-number-of-the-second-kind-identities
– Phicar Aug 18 '21 at 15:48