I don't understand what the function of the preposition of has in the following sentence:
He had the honour of being elected as the new president.
Thank you.
"Of' has a very broad field of meaning.
Here it is used in this sense:
a function word to indicate a particular example belonging to the class denoted by the preceding noun
See https://www.merriam-webster.com/dictionary/of
There are many types of bestowed honor: being president of something is merely one type.
It is a traditional but perhaps stilted way to say
He was honored by being elected president