Question A: How long have you lived there? B: I have lived there all my life.
1) You use the present perfect in /I have lived there all my life/ because at the time of speaking your proposition began in the past and it is still true in the present. You have to imagine the timeline when using verbs in English. Past___Present____Future = the Timeline. If something began in the past and is still true, you need PP.
Simple present is for general propositions that are true in the present at time of speaking: I live in Paris. I live my life to the fullest.
2) Have you ever studied any other languages? B: Yes, I learnt German for two years when I was at school.
Yes, I studied [not the verb learn here] German for two years when I was at school.
The reason: when I was at school. At the time of speaking, you are no longer in school. The condition of being at school is over and finished.
NB: I prefer /to study a language/ than /to learn a language/here. But that is a separate discussion.