Bravo! You've identified the one metaphor in this poem that wasn't immediately clear to me either!
I think the simplest explanation is that Burns is referring to an hourglass that's filled with sand (if you haven't seen one lately, look at the little icon on your computer screen when something is processing and isn't ready yet). As long as the sand is running--i.e., as long as time continues--he will continue to love his beloved. (See the second link below.)
Another possibility is that Burns is referring to the way that sand "runs" up onto a beach and flings debris onto the land. According to this, he is saying that he will love his beloved no matter what difficulties life may "throw" at him. (See the first link below.)
The poem “A Red Red Rose” was written by Robert Burns. In the poem he is describing his love and how strong his feelings are for the person. The color of the rose and its flowering in spring expresses the beauty of his new found love. He expresses how deeply in love he is with the person. He tells several things that are indicative that his love will never end for the person. He states even if the seas dry up and the rocks are melted by the sun, his love for her will continue. Nothing can stop or end his love. When he refers to the line “While the sands o' life shall run,” he is speaking of his death . The metaphor "sands of time" relates to sand in an hour glass pouring down. Time is up when the sands have run out. This is validated by his mention in the next lines that he will have to be separated from her for awhile.
Burns' poem is charmingly simple and direct in its method of praising the lover and most significantly describes how much he loves her:"As fair art, thou my bonny lass/So deep in luve I am."
I will luve thee still, my Dear,
While the sands o'life shall run.
The implication is that he will love her forever, that is, infinity. As long as human life exists on this earth he will love her. Burns uses hyperbole, that is, exaggeration to convey to his lover the depth and intensity of his love for her. In the previous line he has told her that he will love her till all the seas dry up! But he is not satisfied with that, because he feels that there is a possibility that all the seas may indeed dry up so he says that he will love her till all human life comes to an end on planet earth!