However, that's the direct cost — money directly spent on the project. There are indirect costs, too: Joseph Stiglitz estimates the true cost of the war to be $3Tn to the United States, and $3Tn to the rest of the global economy. These are indirect costs, and factor in the long-term additional expenses that the war has accrued — everything from caring for brain-damaged soldiers for the next 50 years through to loss of economic productivity attributable to instabilities in the supply of oil from Iraq.
We can tap-dance around the indirect costs, but the direct costs (that headline figure of $523Bn) are inarguable.
So. What fun boondoggles could we have bought with either $523Bn (at the low end) or $6Tn (at the high end)?
NASA have plans for a manned Mars expedition based on the Ares spacecraft they're developing as a replacement for the Space Shuttle. Price estimates vary from $20Bn (presumably for a single round-trip) to $450Bn (presumably for a single round trip plus all the externalities, like developing the spacecraft and equipment and conducting a thorough prior reconnaissance using unmanned landers).
Either way, the direct costs of the Iraq war exceed the maximum cost estimate for a manned Mars expedition, infrastructure and all, by 20%. If we take $20Bn as the cost per mission and $450Bn as the cost to develop the technology to go there, the direct cost of the Iraq war would be sufficient to develop a gold-plated Mars expeditionary capability and send six crews of astronauts to Mars (and bring them back afterwards).