This psalm was written by Hezekiah around the time of his illness and the invasion of the Assyrians who had surrounded Jerusalem.
The phrase you are asking about is a reversal of the sentence pronounced on him by Isaiah: "You shall die and not live" - Isaiah 38:1. When Hezekiah prayed in response to Isaiah's pronouncement, God added 15 years to his life.
Here is a link to an online commentary on Psalm 118:
I hope you have found this helpful.