וְשַׁבְתִּי בְּבֵית-יְהוָה, לְאֹרֶךְ יָמִים.
The first three words (from right to left)
וְשַׁבְתִּי בְּבֵית-יְהוָה
mean "and I shall dwell in the house of God".
The last two words (from right to left) are
לְאֹרֶךְ יָמִים.
The word לְאֹרֶךְ means "for length"
The word יָמִים means "days" or "time"
The word "of" is implied by the grammatical construction.
So the last two words mean: "length of days" or "length of time". As an expression, they mean "long time". It is used in phrases meaning "long life".
There are two words in Hebrew that mean "forever", and they are לָנֶצַח and לְעוֹלָם. These words are used in the Hebrew Bible several times, but NOT in Pslam 23.
Absolutely nowhere in the Hebrew Bible will you find any promise of eternal life. It simply is not to be found anywhere.
This is the problem with reading a translation and taking it literally.
If you doubt me, look them up in Google Translate.