Why any countable subset of $\mathbb{R}→\mathbb{R}$ is generated by a finite set under composition? Given a sequence of functions $\{g_k\}$, where $g_k: \Bbb R\to\Bbb R$ for all $n\in \mathbb N$. Prove that there exists a finite set of functions
$$f_1,f_2,\ldots,f_n$$ such that any function $g_k$ can be expressed as a composition
$$f_{k_1}\circ f_{k_2}\circ\cdots\circ f_{k_m}.$$

More generally:
Theorem. For any infinite set $S$ and any countable set $F$ of functions $f:S\to S$, there are two functions $g,h:S\to S$ such that $F$ is contained in the semigroup generated by $\{g,h\}$ under composition. (On the other hand, if $S$ is a finite set with more than two elements, then three selfmaps of $S$ are needed in order to generate them all.)
Proof. Let $F=\{f_n:n\in\omega\}$. We may assume that $S=X\times\omega\times2$ for some infinite set $X$. Construct a bijection $g:S\to\{(x,n,i)\in S:n=0\text{ or }i=1\}$ such that $g(x,n,0)=(x,n-1,1)$ for $n\gt0$; thus $g^2[S]=X\times\{0\}\times\{0\}$. Define $h:S\to S$ so that $h(x,n,0)=(x,n+1,0)$ and $h(x,n,1)=f_ng^{-2}(x,0,0)$. Then $f_n=hgh^{n+1}g^2$.
The theorem is due to Sierpiński:

W. Sierpiński, Sur les suites infinies de fonctions définies dans les ensembles quelconques, Fund. Math. 24 (1935) 209–212.

A simpler proof of Sierpiński's theorem was given by Banach:

Stefan Banach, Sur un théorème de M. Sierpiński, Fund Math. 25 (1935) 5–6.

(By the way, if the given functions are bijections, then the functions $g,h$ can also be taken to be bijections; see Theorem 3.5 of Fred Galvin, Generating countable sets of permutations, J. London Math. Soc. (2) 51 (1995) 230–242.)
Sierpiński's theorem resurfaced in Monthly problem 6244, proposed by John Myhill; the solution appeared in Amer. Math. Monthly 87 (1980) 676–678.
Since every semigroup is isomorphic to a semigroup of mappings, as a corollary to Sierpiński's theorem we have:
Corollary. Every countable semigroup is embeddable in a $2$-generator semigroup.
This was proved in a different way by Trevor Evans, Embedding theorems for multiplicative systems and projective geometries, Proc. Amer. Math. Soc. 3 (1952) 614–620.
