Why are “able to [verb]” and “capable of [gerund]” both perfectly valid English, but “capable to [verb]” sounds slightly off and “able of [gerund]” sounds entirely wrong? What’s the etymological reason?
You’ve made a false syntactic dichotomy between infinitives and gerunds as complements to the adjectives able and capable. The distinction is between infinitives and prepositional phrases. Able can take an infinitive, but not a prepositional phrase:
[1a] I am able to paint.
[1b] *I am able of anything.
The object of a preposition could, of course, be a gerund:
[1c] *I am able of painting.
But what’s not licensed is the prepositional phrase, not the gerund as the object of the preposition.
The reverse is true of capable, which can’t take an infinitive, but instead requires a prepositional phrase:
[2a] *I am capable to paint.
[2b] I am capable of anything.
Both words are derived from Old French cognates, but etymology won’t provide an answer. Per the OED, both words in their history in the language have taken as complements both infinitives and prepositional phrases with of and for. For instance, capable to hold once meant “having the capacity to hold”, as of a ship. This usage became obsolete and with it the capability (as it were) of capable to take an infinitive. It’s impossible to say what drove the idiom to its modern state.