Why is 之 used in this sentence?
Cant it just as easily be substituted with 的?
之 and 的 are essentially synonyms for different contexts.
之 is mostly used in set phrases, idioms, proverbs, poems, etc. (Also math with percents and such: 百分*之*百 100 points out of 100. )
的 is more fit for colloquial contexts.
Since 忍耐是幸福之门的一把钥匙 "Patience is the key to the door of happiness" is a phrase, it is fit to use 之.