In Massachusetts, if you buy a vehicle which will not pass inspection, it can be returned to the seller (yes, even private party) for a full refund. There is a time limit, maybe 30 days, I'm not sure. That being said, they can refuse and you'd need to take them to court. Even then, if you get a judgement in your favor good luck collecting the money. I don't know if any of this applies to you, but no one has mentioned the possibility yet so I figured I'd throw it out there.
Sorry this happened, but it happens. Assuming you cannot recover any money, you basically have three choices: Sell it as is (with disclosure), part it out or fix it. Fixing it will let you drive it safely. Whether or not you will be able to enjoy the vehicle is something you will have to decide. It may leave a bad taste in your mouth. Also, you will not recover your money from fixing it.
If you have the ability to part it out, depending on what options it has, this may be a better route, though a lot more work on your part. This depends heavily on options. If it was a Rubi, this would be the way to go, but with the price paid I seriously doubt it is.
You could try to sell it as is, but the problem here is that it is simply not worth very much with a bad frame, which of course you would disclose. Some people (me included) wouldn't even consider it as it is nothing more to me than a parts vehicle at this point.
If it were me, I would first contact the seller to see if they would work with me. Maybe split the cost of the frame repair, or in the perfect situation, take the vehicle back for a full refund. I would also check if where you live has a lemon law like the one I mentioned above that you could discuss with the PO. If this proves fruitless, I wouldn't take them to court, I would just move on....at least that's what I like to think I'd do
Good luck, let us know how it works out, or doesn't.
Edited to add: Some people mentioned above that the PO might not have known how bad the frame was. In all of the TJs I looked before I bought mine, I ran into this quite a bit. Many people simply do not look under their vehicles, and even if they did, wouldn't know what they were looking at. If it was covered with undercoating, it is unlikely the PO would've taken a hammer to the frame to test it. Other than enthusiasts who have dealt with stuff like this time and time again, your average person doesn't give frame rust a lot of thought. That being said, I also ran into a couple VERY unscrupulous sellers that I would've loved to monkey stomp into the ground, but they were much more rare than the ignorant ones.