The entire robbery at the giant's castle in the clouds was part of a sinister plot by Humpty Dumpty to get revenge on Puss and the entire town of San Ricardo. Kitty Softpaws, Jack & Jill, and the thugs at the tavern were all working with Humpty to trick Puss into helping them.
Humpty has always hated the town and has held a grudge against Puss for leaving him to be arrested after he'd pulled off a bank robbery years earlier.
Humpty gets Puss sent to prison. While in prison, Puss meets Jack (of "Jack and the Beanstalk" fame) and learns that Humpty wasn't just after gold when he kidnapped the Golden Goose! The Golden Goose has a gigantic mother bakc at the castle, and Humpty wants the mother to destroy San Ricardo while searching for her baby.
Kitty Softpaws has a change of heart and helps Puss break out of jail. Puss finds Humpty and appeals to him as a brother to save the town. Humpty isn't altogether bad, after all, and agrees to help save the town. He takes the gosling out of town in his carriage, while Puss leads the mother goose to her baby.
The mother goose catches up to them on the bridge leading out of town. Her weight causes the bridge to collapse. Humpty and the baby goose are left dangling from a rope that is held by Puss alone. Since Puss can't save both Humpty and the baby goose, Humpty selflessly lets go of the rope, and falls to his doom.
The mother goose picks up her baby and Humpty's remains and flies home. Meanwhile, the town now hails Puss as a hero, and he pursues Kitty Softpaws amorously.
As the credits roll, wee see that Humpty wasn't killed after all- he's playing with the baby goose on its mother's back.
Thanks John L!