A few minutes prior to Ben's arrival, Luke focused his Force powers to the point that he was able to move his Lightsaber. This, apparently, is the first time he's meditated, something (that we learn from Yoda in RotS) is key to communing with Force Spirits:
You look back at the lightsaber. Then you think of Old Ben. Obi-Wan
Kenobi. The man who gave you the lightsaber. The man who turned your
father into one of the greatest Jedi Knights of all time. The man who
began to train you—before he was killed by Darth Vader. Darth Vader,
the Emperor’s right hand. Darth Vader, who killed your father. You
stop your mind from wandering. You focus on the lightsaber. You know
what Old Ben would tell you to do. Close your eyes. Count to ten,
letting the thoughts clear from your mind. Breathe in and out. In and
out. Until your mind is as empty and bright as a snowfield on a clear
morning. Until you can feel everything around you. As if everything in
the room has a physical shape on the field of your mind. You feel the
great, hot wampa. You feel the smooth, sticky bones of the tauntaun.
Then closer. The mound of snow. The lightsaber.
When he moves out into the snow his delirium (coupled with his extreme state of relaxation) seems to have made him more receptive to a visit from Kenobi:
You decide just to go back to sleep. The cold is so gentle, and your heartbeat seems, now, so superfluous.
The voice sounds like Old Ben’s. But that’s not possible. Old Ben is dead.
Unless you’re dead, too…
And then you realize that you are dying.
Wake up! you shout at yourself. But your eyes won’t open. You cannot raise your head. You are going to die.
The voice is speaking. “Luke…Go to the Dagobah system.” It sounds like Ben. “Find my old teacher, Master Yoda…”
Quotes from Star Wars: The Empire Strikes Back - So You Want to be a Jedi?
Taking the official Star Wars: The Empire Strikes Back novelisation as a source of info, we can also see that Ben was urging Luke to survive, preventing him from sleeping (which would have likely resulted in his death) and having him make sounds that drew Han closer
The apparition spoke with the same gentle authority Ben had always used with the young man. “You must survive, Luke.”
The young commander found the strength to move his lips again. “I’m cold … so cold …”
“You must go to the Dagobah system,” the spectral figure of Ben Kenobi instructed. “You will learn from Yoda, the Jedi Master, the one who taught me.”
Luke listened, then reached to touch the ghostly figure. “Ben … Ben …” he groaned.
The figure remained unmoved by Luke’s efforts to reach it. “Luke,” it spoke again, “you’re our only hope.”