"As for the "what if" of could we have spent the money in different ways that would have been better.... I assume that is rhetorical, but will answer the obvious... of course it could have been better spent."
It's more of a philisophical question. Are there people who still think that the wars we are engaging in will ultimately transform the Middle East, making it less of a haven for terrorists and more friendly to America? If so, an argument could be made that - even with all of the botched execution - it might ultimately make us safer than more reactive measures, like building up border security & beefing up intel.
I am not of that school of thought. Could it work out that way? Stranger things have happened. Based on everything I've seen, though, I think we've done little more than inspire a new generation of terrorists and create an even more unsafe climate for America in the upcoming decades. I think Iraq will end up with a somewhat corrupt government that will do little to inspire the countries around it, and will end up "supporting terrorism" as much as Saddam did (which is to say, not much, but not much difference after all the effort).