It can be shown by the Inclusion-Exclusion principle.
First, count all possible boolean functions. You need to assign values for $2^n$ possibilities and each value can be $0$ or $1$. So there are a total of $2^{2^n}$ boolean functions.
Now let us try to subtract number of functions with a degenerate variable. The degenerate variable can be picked in $\binom{n}{1}$ ways and the we now need to assign values for $2^{n-1}$ variable combinations. So this gives $\binom{n}{1}2^{2^{n-1}}$ ways.
But consider the cases where there are two degenerate variables. They are being counted twice in the above list. So we add the corresponding number to compensate for that. But there is multiple counting of functions with $3$ degenerate variables and we should subtract that and so on.
Repeating this process, and noting that for $k$ degenerate variables, the corresponding count is $\binom{n}{k} 2^{2^{n-k}}$, you get the required result.