It was a joke oath supposedly used by sailors and first employed in writing by Captain Marryat in the 1830s. The idea was obviously a reference to the timbers of a ship, built of wood in those days, being blasted apart - ie broken into 'shivers' or fragments - by enemy shot.