Just because there may exist some patients who are going to lose consciousness (or die) no matter what doesn't mean this technique has no value.
Imagine this. It's the middle of the night. You're in awful pain. Something horrible and unexpected has happened - a car accident, a crime, a house explosion - and you've seen awful things or you're worried about your loved ones on top of everything else. You don't want this to be real. You don't want to experience this. Going away, by zoning out, letting yourself fall asleep, co-operating with the pull you feel towards unconsciousness - that may seem like a good idea. A person telling you not to may actually keep you from letting go and going under, because some part of it is your choice whether to stay conscious or not, at least for some kinds of injury or trauma.
As to why a care provider wants to keep you awake, it's generally so they can ask you things, or get you to help them treat you. This was my experience when a 3am gallbladder attack took me to the ER. It hurt so much and I was so tired and this nurse was all in my face, demanding I categorize my pain "on a scale of 1 to 10" which I find pointless since they never ask you what a 10 would be, and she wouldn't take no for an answer so I basically closed my eyes and wished she would go away, and I would have happily gone to sleep right there, or at my pain level you could have called it passing out from the pain. But she wouldn't let me. She was firm to the point of rudeness and she was demanding. Her position was "I need you to talk to me so I can help you." And in the end I did and she did.
The point is there is much use to the patient staying conscious - it lets you see if things are getting worse or better, lets you gather information, lets you ask them to roll over or sit up - and in at least some cases, asking (along perhaps with slapping as in the movies, shoulder-shaking, or at least physical contact like taking someone's chin and using it to turn their face towards you) does work to keep people from slipping away.