The most important functions of an infinitive in the structure of a sentence are its use as Noun, Adverb and Adjective.
1. As a Subject of a Verb
To err is human.
To beg is a disgraceful act.
In these sentences, the infinitives 'to err' and 'to beg' are functioning as a subject of the verb 'is' and hence they are functioning as Noun.
2. As Object of a Verb
You have learnt to identify a finite verb.
I tried to solve the problem.
In these sentences, the infinitives 'to identify' and 'to solve' are functioning as Object of the verbs 'learnt' and 'tried' respectively and hence they are functioning as Noun.
3. As Complement of Verb
My desire was to become a doctor.
The aim of his life is to serve the down-trodden people.
In these sentences, the infinitives 'to become' and 'to serve' are functioning as complement (subjective) of the verbs 'was' and 'is' respectively and hence they are functioning as Noun.
4. As Object of preposition
He was about to speak the truth.
In the sentence, the infinitive, 'to speak' is functioning as Object of the preposition 'about' and hence it is functioning as Noun.
Look at the sentences:
a. I turned my face to avoid him.
b. Mr. Smith came to teach me English.
In these sentences, the infinitives 'to avoid' and 'to teach' tell us something more about the verbs 'turned' and 'came' respectively, that is, the infinitives are modifying the verbs and hence they are functioning here as Adverb.
Look at the following sentences:
a. My brother gave me a cake to eat.
b. My uncle bought me a cycle to ride.
In these sentences, the infinitives 'to eat' and 'to ride' tell something more about the nouns 'a cake' and 'a cycle' respectively and hence they are functioning as Adjective.
Also See: Types of Infinitives