The story
Originating from the concept of resources that were the means of obtaining control over an actual kingdom, i.e., a realm under the rulership of a king. Compare also King James Bible Matthew 16:19, "I will give unto thee the keys of the kingdom of heaven."
Etymology from Wiktionary, CC BY-SA 4.0.