The Holodeck
I think the greatest invention imagined in Star Trek is the Holodeck. In it, people could live out their imagination freely. If the future Star Trek society is free of violence, war, hatred and malice, it must be because they managed to separate that aspect of human nature into its own domain where it could do no real harm, while also allowing humanity to integrate its shadow in a healthy manner. If only somehow we could recreate that holodeck technology in this world.
But, somehow I feel that is the direction technology is moving. With virtual reality, AI and all the rest of it, who's to say that we cannot at some point in the future live out our wildest dreams in a safe environment, separated from the real world thereby removing the negative impact on the real world, by the darker aspects of human nature.
Carl Jung explored this extensively in his work with the shadow aspect of human nature. When people and societies repress their shadow, it tends to lash out in unexpected and harmful ways. If humanity is to be whole, it needs to integrate the shadow in a way that allows it to exist without causing harm.
Only in that way can we become whole in ourselves and we need that. For there to be peace and harmony in this world.