There is no doubt that the modern perceptions of knights are grossly romanticized. Today, we see movies and games about one hero taking down droves of men with his sword gleaming in the sunlight. However, I'm pretty sure that was not the case. If knights weren't used as noble heroes but not as cannon fodder like the conscripted peasants they found alongside, what was the general purpose or job that a knight was expected to fulfill?
Depends on the period really. The period where the knights have been used in the most massive way would probably be the Hundred's year war opposing the English and the French.
The French had a numerous and wealthy nobility, they could afford the best armor and weapons and were used as a heavy cavalry. Their goal was to flank the English and charge them where they were the most vulnerable (as the English tactic relied a lot on archers they generally tried to charge at them and make them rout to deprive the enemy of their main asset). They would rarely dismount their horses as it would have deprived them from the shock of the cavalry charge and of the speed necessary to reach the English under a rain of arrows.
The English, as stated above, relied a lot on their archers and would try to field as many archers as they could to litterally shower the French with arrows. Their nobility though was far from being as good as the French one and they were therefore almost always outnumbered cavalry wise. As English archers were both really vulnerable and essential to victory, the whole strategy of the English consisted in protecting the archers and that was the role of the English nobility : prevent at any cost the French knights to reach their archers so their role was more as an elite bodyguard troop.
So basically it depended on the country. They were always used as an elite force but what any particular commander made of this elite force would vary.
Check "The battle of Crecy" by Ayton and Preston if the subject is of interest to you. It offers a very in depth analysis of both the armies.