There are a couple of different ways you can construct a stable solar system with a maximum number of habitable worlds. One includes 36 habitable worlds in a single solar system.
We can fit the orbits of four gas giants in the habitable zone (in 3:2 resonances). Each of those can have up to five potentially habitable moons. Plus, the orbit of each gas giant can also fit an Earth-sized planet both 60 degrees in front and 60 degrees behind the giant planet’s orbit (on Trojan orbits). Or each could be a binary Earth! What is nice about this setup is that the worlds can have any size in our chosen range. It doesn’t matter for the stability.
Let’s add it up. One gas giant per orbit. Five large moons per gas giant. Plus, two binary Earths per orbit. That makes 9 habitable worlds per orbit. We have four orbits in the habitable zone. That makes 36 habitable worlds in this system!