There are so many interesting and wonderful versions of this story and resulting quote. Here are two that I particularly like.
The first one is an excerpt from Eckhart Tolle’s book A New Earth….
According to an ancient Sufi story, there lived a king in some Middle Eastern land who was continuously torn between happiness and despondency. The slightest thing would cause him great upset or provoke an intense reaction, and his happiness would quickly turn into disappointment and despair. A time came when the king finally got tired of himself and of life, and he began to seek a way out. He sent for a wise man who lived in his kingdom and who was reputed to be enlightened. When the wise man came, the king said to him, “I want to be like you. Can you give me something that will bring balance, serenity, and wisdom into my life? I will pay back any price you ask.”
The wise man said, “I may be able to help you. But the price is so great that your entire kingdom would not be sufficient to pay for it. Therefore it will be a gift to you if you honour it.” The king gave his assurances and the wise man left.
A few weeks later, he returned and handed the king an ornate box carved in jade. The king opened the box and found a simple gold ring inside. Some letters were inscribed on the ring. The inscription read. This too will pass. “What is the meaning of this?” asked the king. The wise man said, “Wear this ring always. Whatever happens, before you call it good or bad, touch this ring and read the inscription. That way you will always be at peace.”
And a lovely Hebrew version….
One day Solomon decided to humble Benaiah Ben Yehoyada, his most trusted minister. He said to him, “Benaiah, there is a certain ring that I want you to bring to me. I wish to wear it for Sukkot which gives you six months to find it.”
“If it exists anywhere on earth, your majesty,” replied Benaiah, “I will find it and bring it to you, but what makes the ring so special?”
“It has magic powers,” answered the king. “If a happy man looks at it, he becomes sad, and if a sad man looks at it, he becomes happy.”
Solomon knew that no such ring existed in the world, but he wished to give his minister a little taste of humility.
Spring passed and then summer, and still Benaiah had no idea where he could find the ring.
On the night before Sukkot, he decided to take a walk in one of the poorest quarters of Jerusalem. He passed by a merchant who had begun to set out the day’s wares on a shabby carpet.
“Have you by any chance heard of a magic ring that makes the happy wearer forget his joy and the broken-hearted wearer forget his sorrows?” asked Benaiah.
He watched the grandfather take a plain gold ring from his carpet and engrave something on it.
When Benaiah read the words on the ring, his face broke out in a wide smile.
That night the entire city welcomed in the holiday of Sukkot with great festivity. “Well, my friend,” said Solomon, “have you found what I sent you after?”
All the ministers laughed and Solomon himself smiled.
To everyone’s surprise, Benaiah held up a small gold ring and declared, “Here it is, your majesty!”
As soon as Solomon read the inscription, the smile vanished from his face.
The jeweler had written three Hebrew letters on the gold band: gimel, zayin, yud, which began the words “Gam zeh ya’avor” — “This too shall pass.”