Can the universe be unbounded and yet have a finite amount of stars and galaxies? As I understand it, if the universe has flat curvature it must either be unbounded (infinite), or have a non trivial topology (a multiply connected shape, like a 3 torus). If it were bounded, there would be a finite amount of "stuff" in it, like stars and galaxies. 
But what seems absurd to me is that if the universe is unbounded, people seem to say there must be stars and galaxies that go on forever, eventually repeating the same configuration of matter right here on earth. So you have infinite, infinitesimally different earths scattered throughout the universe. Infinite empty space makes some sense to me, but infinite galaxies does not.
So my question is: is it possible to have a unbounded universe with a finite amount of stars and galaxies in it? Or is that mathematically impossible due to how it would affect the topology of the universe?
 A: An unbounded universe with a finite amount of stuff is perfectly possible: consider a universe consisting of a single star or, more simply (because you don't have to worry about the light from the star & the resulting time-dependence of its mass &c), a Schwarzschild solution.  That's asymptotically flat, unbounded, and contains a finite amount of mass.
But it doesn't look much like the universe we live in.  And that's why we consider that the universe, if it is unbounded, should contain an infinite amount of stuff: we believe that the cosmological principle is true.  If the universe is unbounded and (on large scales) homogeneous, then either it is empty (or, rather, the density is zero everywhere, which perhaps might not be the quite same thing), or the amount of stuff in it is also unbounded.  Well, we observe that it is not empty near us so, if it is homogeneous and unbounded then either the cosmological principle is false or there is an unbounded amount of stuff.
Finally, if we want to assume that the cosmological principle is false, then we need to assume that we exist at some very special place in the universe ('the centre'), which seems deeply implausible.
A: In simple popular terms, from what we currently know in cosmology and physics, if it is indeed infinite it must have an infinite amount of matter and energy. The only way out is if General Relativity (GR) is not valid in macroscopic space, or if the observable universe we live in and see is a very special part of the whole universe.     
More correctly, if the universe is infinite (correctly meaning unbounded) it has to have an infinite amount of mass/energy, if our scientific understanding of the universe is right, we use the terms correctly, and our universe has a so-called simple or trivial topology (more on that below, it's not complicated).     
Unbounded means, technically, that for any distance d one can always find 2 points that are further apart than d. It is another way of saying it is infinite, but it is more precise. Also, to be clear, one usually means spatially unbound, but one can also mean unbound time wise. For our universe, people usually are asking whether it is spatially infinite, meaning unbounded. 
The case where one is referring to say a 3D sphere as the spatial universe is not considered unbounded, and it is not unbounded according to the technical definition above. However, the 3D sphere is considered as having no edge, edgeless, since you can travel in any direction on the 3D sphere without falling off (no edge). The 3D sphere is bounded, and thus considered finite, but has no edge. A finite or bounded universe has a finite volume, and thus must have finite mass/energy. 
See the possible classifications for the universe and the definition of terms in  https://en.wikipedia.org/wiki/Shape_of_the_universe. It is a very clear and easily understood description of the options
If it is unbounded, i.e. infinite, it also must have infinite volume, and it also THEN must have infinite mass/energy IF it is like our universe. The observations and mathematical assumption is that it has, on a large scale, uniform spatial regions, that is, it is spatially homogeneous. More on this for our universe below, and what happens if this is not true. Thus, with those observations our universe would have infinite mass/energy if it is unbounded, i.e., infinite.
Note, from the Wikipedia reference above, that if the universe is flat or open, it could be either bounded or not (finite or infinite). And if its topology (meaning in the next sentence) is simply connected or has the Euclidian topology (called the simple or trivial topology, because it is what we are used to), it must be infinite. There are non-trivial topologies which are flat or open geometries which are bounded: for flat, one example is the 3D torus, another the 3D Klein bottle. For open the geometries are hyperbolic and could also be bounded if not simply connected, and there is a large number of possibilities not all well understood. If then the universe is finite, bounded. It requires a 'strange' topology, meaning non-'simple', meaning multiply connected. We have observed no evidence of anything in the universe (and there's been some searches, some ongoing) that indicates that the topology of the universe is not the simple topology on a large scale (eg, we have seen no examples of galaxies we see in one direction that we also can see in another direction), but it could be the case on a larger scale than what we see. No physics prevents it from being the case. We just have not seen any strange topology.    
So, what does it mean IF it is like our universe? It means if it conforms to what we observe, with whatever uncertainties we have, and to General Relativity (the best theory we now have for how matter/energy bends spacetime). We observe our universe, as far as we can see, as roughly uniform, ie spatially homogeneous and isotropic. The statistics are pretty god, on a large scale (ie, taking spatial sizes of 100-200 Mpsec or more), with small variations. Since we think, and there is is no scientific reason why that is not so, that we don't live in a special part of the universe, we say the whole universe is like what we see, ie homogeneous and isotropic. Notice that we do not assume it to be infinite or finite. That comes below. 
The infinite or finite is related to, but not the same as, the shape of the universe, and specifically the curvature of space (ie, the spatial curvature). Specifically, we can determine the universe's spatial curvature from observations of the mass/energy density, the universe's expansion, and General Relativity (GR) which relates geometry (ie, curvature) to mass/energy density. GR derived that the only possible solution for homogeneous and isotropic space geometries is the so called Robertson-Walker solution. Along with measurements of the expansion and the mass/density, and some more physics, we get the FLRW (Friedman-Lamaitre-Robertson-Walker) solution, and the Lambda CDM Model. The latest measurements are that the universe is flat, within the accuracy of the measurements. It turns out the measurement uncertainties still allow for very small positive or negative curvature. See the Model at https://en.wikipedia.org/wiki/Lambda-CDM_model.
So, more than likely our universe is flat and infinite, or open with very small curvature and also infinite, or closed with a small curvature and very very large, but finite and with finite matter/energy
If infinite the mass/energy is also infinite, if the universe in the large is indeed uniform (homogeneous and isotropic) everywhere on a large scale -- if we do not live in a very special part of the universe (which measurements have shown we do not, out to the observable universe 48 billion light years away) and outside what we see things are very different.
Is it possible that our universe is not uniform: yes, anything is possible, but if it the universe is topologically trivial, it is very hard to find a solution to the GR equations and the physics we know that looks like ours out to x many billion light years away, but then changes and becomes say empty space. Your question about a solution with no mass out there, but with FLRW where we can see, may be possible, but also it may not. Certainly the Schwarzschild solution does not do that, and you would not be able to stitch them together because our universe expands everywhere and Schwarzschild does nowhere. Solutions to GR equations may not be possible if you assume totally empty space out there somewhere and out. But I have to admit, I have not seen a theorem that proves that it is impossible, just agree with @tfb that it is unlikely
If the universe had a center and an end (ie, be bounded or have an edge, and be spherically symmetric on a large scale -- which is what having a center means), there is a theorem by Birkhoff that any 'spherically symmetric solution of the vacuum field equations is necessarily isometric to a subset of the maximally extended Schwarzschild solution'. This means that the exterior region around a spherically symmetric gravitating object must be static and asymptotically flat. See the quote in, and more description in https://en.wikipedia.org/wiki/Spherically_symmetric_spacetime
And of course that can't be because our universe is not static, we see it expanding. We can see it expanding going back to close to its origin about 13.8 billion years ago. We see the CMB, cosmic background radiation, coming from about 380,000 years after the Big Bang, and we see proof of expansion from redshifts of the light of galaxies emitted way in the past and through the expansion. 
So you'd be hard pressed to find any evidence that would make what you say possible. 
Your question about the mathematical possibility is that probably yes, if you ignore our observations and GR. Yes, there could then be such a spacetime, it might even be a differentiable manifold (which is part of the mathematical definition), but as soon as you impose the observation and GR constraints it probably would not be possible, from the many reasons stated in this answer.   
