It originated from the days of wooden sailing ships. If the timbers of a ship were to shiver, it meant they were cracking and breaking, indicating serious damage and potential disaster.
So, when someone says "Shiver my timbers," they're essentially saying something along the lines of "That's unbelievable!" or "I can't believe what I just heard!"