To be secure is, at its Latin root, to be carefree. The word comes from sēcūrus — sē ('without') plus cūra ('care, anxiety'). A secure person was not originally someone behind a locked door, but someone with nothing to worry about.
The shift from psychological peace to physical protection happened gradually. If you are without care, nothing threatens you. If nothing threatens you, you must be well defended. By the 16th century, English had completed the transformation: secure meant 'firmly fastened' as well as 'free from worry'.
The Latin cūra is one of the most productive roots in English. A cure is care for the sick. A curator is one who takes care of a collection. Curious originally meant 'full of care' — attentive and diligent. Accurate means 'done with care'. All these words share the same ancestor.
Sure is secure with the first syllable eroded away. French wore sēcūrus down to sûr, and English borrowed it as sure. Assure, insure, and ensure are all built on the same foundation. Spanish seguro preserved more of the original Latin, and it means both 'safe' and 'insurance' — the commercial product being a promise to make someone secure.