Since I'm an etymology geek, and I enjoy diving into the history of where things come from, I add this as an addendum to naruto's explanation.
Translated from Shogakukan's monolingual 大国語辞典【だいこくごじてん】:
Verb ending / suffix. Classed as a 助動詞【じょどうし】 (auxiliary verb).
Developed from fusion of classical あり with the preceding verb stem.
- Indicates continuation or progression of the action of the main verb. Equivalent to modern -ている・-てある.
- Indicates ongoing state as a result of the action of the main verb. Equivalent to modern -た・-ている・-てある.
- Indicates a sense of confirming that the action of the main verb has completed.
For conjugation purposes, this -り was previously analyzed as attaching to the 已然形【いぜんけい】 (realis) stem of regular 四段活用【よだんかつよう】 (quadrigrade conjugation) verbs, the -e ending corresponding to the modern 仮定形【かていけい】 (hypothetical or conditional), or to the 未然形【みぜんけい】 (irrealis or incomplete form) of the irregular "s" verbs (such as modern する), which also ended in -e.
However, further research into ancient kana usage (上代特殊仮名遣い, or in English, "ancient special kana usage") revealed that there were two kinds of -e vowels, called 甲類【こうるい】 and 乙類【おつるい】 in Japanese and usually subscripted as "1" and "2" in English. It was also revealed that the -り ending attached to the 甲類 version of -e, that is, the verb stem ending in -e1, which is the 命令形【めいれいけい】 or imperative form, rather than the 已然形【いぜんけい】 or realis that ended in -e2 in Old Japanese.
Still further research into the vowel values of Old Japanese (OJP) suggests that these two "flavors" of the e vowel may have arisen through the fusion of earlier vowel sounds, much as we see even in modern Japanese in words like takai or sugoi becoming takē or sugē in informal speech.
From this, and from oddities in how the -り ending attached to different verb classes (such as the "s" class, or 上一段【かみいちだん】 (upper monograde) verbs with "k" stems, where the 命令形 ending is -kiyo, but the stem becomes -ke before -り), the growing consensus view appears to be that this -り is really just あり attaching to the normal 連用形【れんようけい】 or conjoining form. For most verb classes, this ends in -i, and this then combined with the a- in あり as a kind of contraction, something like:
- -i ari → -yari → -yeri → OJP -e1ri → classical -eri
So in classical and modern Japanese, the conjugation to use the -り ending seems very irregular: attaching to the imperative for yodan verbs, the irrealis for "s" verbs, and a completely irregular -ke ending for kami ichdan verbs. But if you dig back, it turns out it might actually be very regular indeed, with just a couple millenia of contraction obscuring the origins.