My personal feeling is that the USA wanted to neutralize him in such a way that they didn't have to actually ever take custody of him and the negative publicity that would entail, and that Mr. Assange's sense of privilege handed the CIA an opportunity on a silver platter. Whether they set him up, or just dug up existing dirt on him and made sure it became public knowledge is an open question, but the second case requires far fewer assumptions to hold based on what we know now, and is therefore the more likely one.
The spy game isn't like the movies kids: it's a results oriented business, and sometimes your targets personal failings are actually your biggest assets.
Our OS who art in CPU, UNIX be thy name. Thy programs run, thy syscalls done, In kernel as it is in user!