He was painted into a corner with seemingly no way out.
People who are suicidal frequently have intractable problems and are frequently treated like they are merely crazy. The best way to help people who are suicidal is to not be dismissive of their very real problems and, of possible, actually be helpful. But as a baseline, don't act like it's all in their head. That actively makes it harder to solve intractable personal problems.
That's a common misconception, largely due to the ridiculous way the DoJ writes its press releases.
Each Federal crime carries a range of possible prison time. What you actually get depends on a large number of factors, such as how much damage you caused, whether or not your crime was a drug crime, past criminal history, and many others.
When the DoJ writes press releases they just add up for each charge the maximum that it is theoretically possible for someone to get from the crime if they hit all the factors that push for longer sentences and none of the factors that push for shorter sentences.
So when they arrest you for crime X and write their press release, they don't actually tell what you, the first time offender who committed a mild instance of the crime with no aggravating factors and several mitigating factors is facing. No. They tell what the Voldemort or Moriarty or Hitler of whatever activity you were doing would face for crime X.
It is even worse, because they actually even exaggerate what Voldemort or Moriarty or Hitler would actually face, too! If a person is charged with multiple crimes from the same underlying act, say crimes X, Y, and Z, and is convicted of all of them the crimes are grouped together into one for sentencing, with the sentence for the group being the sentence you would have received for whichever for X, Y, or Z you would have gotten the longest sentence for if that was the only one you were convicted on.
Here's a good article on this in general: "Crime: Whale Sushi. Sentence: ELEVENTY MILLION YEARS." [1]
Here's a couple articles specifically on the Swartz charging.
This one covers the charges themselves: "The Criminal Charges Against Aaron Swartz (Part 1: The Law)" [2]
This one covers the prosecution, including a look at probably sentencing: "The Criminal Charges Against Aaron Swartz (Part 2: Prosecutorial Discretion)" [3]
[1] https://www.popehat.com/2013/02/05/crime-whale-sushi-sentenc...
[2] https://volokh.com/2013/01/14/aaron-swartz-charges/
[3] https://volokh.com/2013/01/16/the-criminal-charges-against-a...
(and if someone is reading this who is mentally in a bad place right now, please seek out some help: https://suicidepreventionlifeline.org/)