It's a question of whether you want to be precise or ambiguous. If you say "ONLY kings, pharaohs and emperors" then you are excluding everyone else, but if you say..."Thousands of years ago, kings, pharaohs, and emperors..." then you are not excluding anyone, per se, you are simply choosing to concentrate on these three types of people. So in one sentence ONLY these three could solve large-scale problems, and in the other sentence it COULD ALSO be priests, sailors, businessmen, children and shoe salesman, but you only want to talk about kings, pharaohs and emperors.
Likewise, if you say "THE ability" then you are implying that there is only one method by which these rulers solved large-scale problems. If you say "AN ability" then you are implying that there may be many methods to solve these problems, and these rulers choose ONE of them.
Your second example...."I believe gays have an ability to see beauty"... is written to be ambiguous. They have "AN" ability to see beauty, which implies that there could be many ways to see beauty. When it comes to the topic of beauty you almost have to be ambiguous.