NOTE. In this post I consider functions having only local minima, instead of maxima. Also, this is not a rigorous solution but only a hint.
There is a similar problem which asks to find a two-variable function that is unbounded above and below and that has only one critical point that is a local minimum. I saw somewhere the solution by Tim Gowers, which is the following recipe.
Take the graph of $f(x, y)=x$ and put a finger in it, at $(x, y)=(0,0)$. This creates a local minimum that is not global. This also creates a saddle point near the point $(x, y)=(-1, 0)$. Sliding the finger in the negative $x$ direction, the saddle point moves accordingly. Passing to the limit, we can make the saddle point disappear, as if it had "moved to the $x, y$ infinity". Done.
(Unfortunately I cannot find the precise reference. It is in a comment to some blog, so it is not indexed by search engines, I think.)
You can redo this recipe countably many times, each time putting your finger far from what you have already done. This will produce an unbounded function with countably many local minima that are not global, and no more critical points.