Be consistent because consistency is the key to learning a language.
Why is there -ing after to and not infinitive form? What is the difference? Is it incorrect to say consistency is the key to learn a language.
Consider "the key to the door" for example. "To the door" is an adjective phrase modifying "key".
Similarly in "the key to learning a language", "to learning a language" is an adjective phrase.
It consists of the preposition "to" and the gerund phrase "learning a language" which serves as the object. There is no infinitive involved.
If this does not help, study more about gerunds and gerund phrases.