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.