In a curved stone archway, the keystone is the one at the very center of the top. The keystone is the most important stone, and that's why this word is also used figuratively to mean the most important part of anything.
A stone arch or vault gains its stability from the placement of the keystone, which is often the last one placed. From this architectural meaning, keystone also gained the figurative meaning of "central or most important part," or "the one thing upon which everything else depends." Like an actual stone keystone, this type lends stability: "The right to free speech is the keystone of all American rights."