The thermocouple is reponsible for making enough electricity to hold the electric valve open in the gas control. The size, duration and steadiness of the pilot flame on the thermocouple is important to making that. Too high a flame or too directed (like a blowtorch on a spot) a flame can burn it out early. The flame should be easy around the upper middle of the thermocouple. Dirt or drips on the pilot light can reduce the pilot flame. Bad connections will reduce the already small amount of electricity.
If all these are alright the thermocouple should work. They are inexpensive enough to buy a new one. If the new thermocouple makes the system work, then you solved the problem for the while. Even if it was one of the other problems, the shaking and moving of the parts and wires may have made the connection tight and the flame better.