Sugar is hygroscopic - it absorbs moisture from it's surroundings, including the air. If you put an unopened paper bag, or cardboard box, of sugar on the shelf for a few weeks or months it will absorb moisture thru the paper bag. Since you noted that you "came across this in the cabinet" I'm going to venture a guess that it has been there for a while. It's just a matter of time+humidity+temperature.
I agree with Haggis. To prevent this in the future - store it in an air-tight container of some sort and store in a cool dry place (the cabinets over the stove, under the sink or above/beside the dishwasher are usually the most humid areas in the kitchen). Even putting the bag in a zip-lock freezer bag (freezer bags are less porous than the regular bags) and squeezing out as much air as possible will help until you can get a proper storage container.
Rescue is probably best done as Haggis suggested - put it inside a couple of freezer bags and whack it with a smooth heavy mallet, rolling pin, a big stick like a baseball bat or a hunk of 2x4, etc. until you break it up a bit into small chunks. You can then put some into a dry food processor bowl with the steel blade in small batches and pulse a few times until it breaks down into granuals again. One thing you don't want to do is just pop a bunch in the food processor and just turn it on to run for a few minutes ... unless you don't mind it being reduced to super-fine texture.
"It ain't what you don't know that gets you in trouble. It's what you know for sure that just ain't so." - Mark Twain