Ordinary generating function can be used to solve combinatorial enumeration problems.
Now if the energy levels are discrete, say $g_i$, and if one want to count how many ways one can add up $g_i$ to get an energy level $G$, the ordinary generating function can be written as $$\sum_{n_i\ge0} x^{\sum_i g_in_i}$$Where $n_i$ is the number of particles in energy level $g_i$, and the number of ways to get energy level $G$ can be read off as the coefficient of the term $x^{G}$ (This is the same as Polya's coin change problem in combinatorics).
If you collect the terms by total number of particles, and for system with only one particle, you get $Z =\sum x^{g_i}$, now you can get the number of ways n particles form a system of energy G by read off the coefficient of the $x^{G}$ term of the function $Z^n$.
And if you write $x$ as $e^{-\beta}$, $Z$ becomes partition function, is there any other relationships?