Great!

So inside a solenoid like that is a moving plunger with a set of copper contacts. Over time these get dirty as they arc much like it does with a screwdriver (to a lesser extent). Now you have pulled it out, the dust inside will have moved around and the contacts will be working again.

Good idea to replace it as it will likely fail again.