Our universe is supposedly 13+ billion years old and our Sun is a third generation star. It seems to me that we are now in a relatively young stage of the universe. How many generations of stars will there be before the end of the universe? When is 'now', relative to the all possible timepoints in the universe, that life could appear?
Here's a very roughly calculated partial answer.
A first generation star and solar-system would obviously not be a good candidate for life or even planets cause you can't do much with mostly hydrogen and helium. You can't even build an ocean with mostly those 2 elements. Stars do just fine, but planets don't. Gas Giants and Suns only.
After the big bang: 75%-76% Hydrogen by mass, 24-25% Helium (with a teeny-tiny trace amount of Lithium). I'm going to assume 76% / 24% for rough calculations.
Using our solar-system and the Milky-way as a model, elements by mass:
Smaller amounts of Argon, Calcium, Nickel, Sodium, Phosphorus, Chlorine, etc.
and composition of the Sun by mass (pretty similar except for more Helium)
Using these numbers as a rough guideline, if 1.9% to 2.1% of the baryonic mass of the milky-way converts from Hydrogen to Carbon or heavier elements after (about) 2 generations, and we extrapolate a 1% increase in all Carbon or heavier elements to each stellar generation or every 6 billion years, then we can begin to make an estimate.
Helium percentage could stay somewhat constant at about 24% cause it's both consumed and created stars.
Your original question, how many generations, if we figure 1% increase in heavier elements (Carbon or higher) per stellar generation, 10 generations we're still looking at, very roughly, (24% helium), 66% hydrogen, 5% oxygen, 2%-3% carbon, 2%-3% other elements. It still looks like a workable scenario to me though the stars, being made of some denser elements might have denser cores and as a result, could burn hydrogen a bit faster. Past a certain point the ratios probably stop being ideal but I see no reason why quite a few generations couldn't still work create life-friendly solar-systems.
Our sun is expected to cast off about half it's matter into a planetary nebula before it settles down into a white dwarf and most of that cast off matter will be hydrogen and some helium. Some time later if our sun as a white dwarf accretes enough to meet the Chandrasekhar mass and goes Type-1 Nova, it will again cast off a significant percentage of it's matter, so, to put it simply, Stars recycle a pretty good percentage of their hydrogen and helium, which is kinda cool. If you see Rob Jeffries' brilliant answer here, stars of 7-9 solar masses will eject an even higher percentage of their elements before they go white dwarf, as much as 85% and most of what gets ejected is the lighter elements, hydrogen and helium from the outer layers. Even smaller red-dwarf stars expel a percentage of their elements due to more active solar flares and lower gravity throughout their lives.
Add to this, the possibility of continued merger of the galaxies and dwarf galaxies in our local group, and life capable solar-systems could continue to form for quite some time, perhaps several tens of billions of years.
This answer isn't meant to be definitive, but only a rough estimate. Corrections welcome.