If the explanation is a verb, use to, as in, “learning a language to communicate.” If the explanation is a noun, use for, as in, “learning a language for communication.”Use “to” when the reason or purpose is a verb. Use “for” when the reason or purpose is a noun.
The English language can be confusing at times, particularly when it comes to knowing when to use the word "to". To help clear things up, let's take a look at when to use "to" in a sentence.
Generally speaking, you will use "to" when you are indicating direction, telling someone what you are going to do, or creating an infinitive verb. For example,
In each of these cases, "to" is used to show direction, convey an intention, or create an infinitive verb.
There are, of course, exceptions to every rule. In some cases, you may see "to" used without any of these purposes. For example,
Here, "to" is used to show possession or create an adjective.
Hopefully this has helped clear up when to use "to". Just remember, if you're ever unsure, you can always consult a dictionary or grammar guide.