The exact quote from The Glass Menagerie by Tennessee Williams is found in the final scene of the play. It is spoken by the narrator, Tom Wingfield, and it reads this way:
I didn't go to the moon, I went much further--for time is the longest distance between places.
This line is spoken after Tom, unhappy with the life he had been forced to live, has moved out and moved on with his life. This leaving should not surprise us, for he was ready to leave when the story began.
Tom is Amanda Wingfield's only son, and and he has had to take his father's place in many ways. His sister, Laura, is a fragile young woman, and he feels a responsibility to her much more than to his mother who is probably the reason his father left so long ago. He has a poetic soul and wants to be a writer; he also wants to join the merchant marines and travel, see the world. Instead he works in a shoe factory and hides in cupboards so he can write. His nickname at work is "Shakespeare," but he is not doing anything he wants to do.
When he can take it no longer and once Laura has had a kind of breakthrough with Jim, her gentleman caller, Tom leaves. He has been escaping by going to the movies, but when he has done his best and grows weary of being called selfish by his mother, Tom leaves and never returns. The last thing his mother says to him (when she thinks he is just going to the movies again) is: "Go, then! Then go to the moon--you selfish dreamer!"
This is where Tom becomes the narrator again, telling us what has happened in the time since he left.
I didn't go to the moon, I went much further--for time is the longest distance between places. Not long after that I was fired for writing a poem on the lid of a shoebox.
I left Saint Louis. I descended the step of this fire-escape for a last time and followed, from then on, in my father's footsteps, attempting to find in motion what was lost in space--I traveled around a great deal.... I would have stopped, but I was pursued by something.
That expression is a simple reminder that physical space--the literal distance between two points--is easier to traverse (cross, overcome) than time. Time can be an insurmountable distance for those who have regrets and longings or who have a connection to the past which they cannot break.
Tom tried to leave Laura by putting distance between them, and he was successful; however, time has not allowed him to forget her.
Oh, Laura, Laura, I tried to leave you behind me, but I am more faithful than I intended to be!