Just a reminder to people: if you remove anyone who has (or will have) children, from a certain moral perspective you’re responsible for them never existing, which could be considered akin to murder. Just take that into account in your considerations. Might make this a much thornier question, ethically, for some.
Energy-to-(organic)matter conversion + futuristic power generators makes feeding your population a triviality. That simplifies just about any economic system, which takes a lot of the complicated stuff out of government and class hierarchies.
But Star Trek is a fictional utopia, much like Communism.
In reality, corruption would still mess up government in a “real world” Star Trek. I’m a casual Trekkie, but I don’t recall much detail about the Federation’s or Earth’s government structure. Do people still vote? Is it a benevolent military dictatorship? Who knows? And who cares? It’s not really relevant to the themes of the shows.
Star Trek is founded on liberal ideas popular in the mid-20th century that humanity could achieve unity and peace if it just cast aside superficial differences like race and gender, allowing us to focus on exploring the universe once we’d gotten over fighting each other. That’s the very core of the entire franchise and I’m fine leaving it that way, unscrutinized, since it clearly doesn’t hold up to scrutiny. It’s like how the force is best left a mystical property of the universe in Star Wars, rather than science-ized with medichlorians.