To solve most problems of this nature you have to think about motives such as influence, power, and money. It has always been this way with mankind. If organizations such as these don't have an enemy that they can convince their people they're fighting against in order to protect them, then none of the motives would be met. Why would there be a need for leadership teams? Why pay for soldiers if there isn't a fight? Fighting is part of the economy in the Middle-East like tourism is to Italy.
Weapons are a huge market. Technology has even become big as these terrorists organizations aren't the goat herders of old. Because these countries are usually under trade embargos, the black market for food supplies, technology and weapons, is huge and countries like China, France, Germany, and Russia make a lot of money off the instability in the Middle-East. They are caught frequently not following U.N. sanctions but aren't cited which is something Trump is so irate about.
So the bottom line is that many countries instead of pushing for peace, stay out of the process. They quietly sit back while making billions of dollars in the black market. Even though they don't want to admit it, they don't want us out of the Middle-East (with the exception of Syria which Russia is using for a strategic military location), because we're the ones creating demand for their illegal products. We don't have to be a Sherlock Holmes to realize that we just have to follow the money to find the answers we're looking for.