The purpose لِ attaches to an imperfect and explains why the earlier action happens.
خَلَقَ اللَّهُ النَّاسَ لِيَعْبُدُوهُ — Allah created people so that they may worship Him.
خَرَجْتُ مِنَ الْفَصْلِ لِأَشْرَبَ الْمَاءَ — I left the classroom to drink water.
It is called Lām Kay or Lām Ta‘līl. In this lesson it is the purpose lām; not every lām has this function.