When I am with you, we stay up all night. When you're not here, I can't go to sleep. Praise God for those two insomnias! And the difference between them.
Two sleepless nights can look alike from the outside, yet one is full of joy and the other full of ache, and Rumi gives thanks for both. Being awake with the beloved means being so absorbed in conversation and presence that sleep feels like a waste. Being awake without the beloved means longing. The gratitude is for the contrast, because the pain of absence shows how much the presence matters.
This rests on the Sufi view that longing is itself a path to the divine. Rumi's poetry often treats separation as a sign of love, and the beloved can be read as God, as his teacher Shams of Tabriz, or as both. Be aware that this wording looks like a loose modern English rendering, so the exact phrasing may not match anything in his Persian.
Today, imagine someone whose close friend has moved overseas. Lying awake missing that friend, they could stop treating the restlessness as a problem. They could take it as a reminder of what matters and send a voice message or plan a visit, grateful to love someone enough to feel the gap.