Came across this article, and it's a very interesting take on how Star Trek has changed with the times, and how modern audiences seem to have a harder time trusting institutions or imagining Trek's utopia.
I've admittedly still only watched up through the 90s, but I'd definitely say that DS9 depicted a significantly more "morally gray" version of Starfleet than TOS or TNG.
I think the point the author is making is that the extent to which this idea gets explored is reflective of our society's growing mistrust of institutions IRL, rather than suggesting the theme has never been explored.