I am reminded of A. E. van Vogt’s The Weapon Shops of Isher. If you are not familiar with this bit of 1950s science fiction, you should be.
Weapon Shops is at least tied for first among my favorites. I have over thirty different Van Vogt books, including a quite rare copy of Slan. Dune is a close call. Dune plus the first chapter (maybe the first word, if my memory serves) of Dune Messiah might provide a clue to the question “why is there terrorism?”