You can save him by first defeating the Spatters around the area, then by using a Spin Move on a gear located in the center of the area. After freeing him, he tells you of some levers he activated, and he also activates the Magic Carpets for you.
Trivia[]
In the game code, Sam is referred to as Gremlin Loo.
If you ignore Gremlin Sam and free every other caged Gremlin, Gus will still give you the Gremlin Guardian pin at the end of the game. This is probably a glitch.