The simplest explanation for the longevity of the Miranda and Excelsior is that they outlived their potential replacements. Both classes must have enjoyed the surplus of parts from the designs being built for so long, and every technological upgrade had the previous generation to fall back on in case of problems.
My headcannon also believes that the Miranda and Excelsior are "wartime" surplus. Like most modern-day cold war developments they were built for a hypothetical wartime engagement with the Klingons, so they had to be durable (Excelsior) or easy to function (Miranda). These factors kept them in circulation as peacetime designs came and went, bowing to either excessive specialization or unjustifiable construction costs. For example, I can believe after time starfleet compared the Ambassadors to the nth generation Excelsior and picked the latter to divert resources to, since they were cheaper and did the job already to a satisfactory degree.
Following this yarn, perhaps Starfleet eased into an era of 'super prototypes'- small production runs of highly specialized ships and all-powerful flagships. It's probably this kind of environment that spawned the Galaxy Class, which is both. The backbone of starfleet- the aging Excelsior and Miranda classes- could persist. They did well enough in the wars against the Cardassians- a contemporary adversary- but threats from the Borg and Dominion finally forced the classes out of their comfort zone.
The three main uses of the Reliant studio model in TNG and DS9 were the Lantree, the Brattain, and the Saratoga. For the first ship, it was quite clear that it was an old ship relegated to transport duty. However, the Brattain was a science vessel and the Saratoga was a ship-of-the-line, both clearly on active duty. All three uses of the model were predicated on them not wanting to spend money building a new transport ship, science vessel, or other new ship of the line. And because the filming model lasted long enough to be scanned into a CGI model, it then appeared a multitude of times in DS9 and VOY as generic Starfleet vessels.
But I don't think they outlived their potential replacements. As I mentioned above, they were just generic ships that we happened to see a lot of during wartime because, well, that's what we happened to see at the time. We would have to imagine that other battles we didn't see contained other classes of ships that were not composed predominantly of Excelsiors and Mirandas.
Last edited: