BB-8 woke him up, but like his typical snarky self, he took a while to get out of bed.
There's an article by Entertainment Weekly which recounts a post-screening Q&A with Abrams and co-writers Lawrence Kasdan and Michael Arndt.
It explains how R2-D2 came to have part of the star map: “BB-8 comes up and says something to him, which is basically, ‘I’ve got this piece of a map, do you happen to have the rest?’”
Abrams said.
“The idea was, R2 who has been all over the galaxy, is still in his coma, but he hears this.
And it triggers something that would ultimately wake him up.”
The director acknowledges that R2’s sudden “awakening” at the end was designed to be an emotional storytelling utility: “While it may seem, you know, completely lucky and an easy way out, at that point in the movie, when you’ve lost a person, desperately, and somebody you hopefully care about is unconscious, you want someone to return.”
So for those let wondering:
BB-8’s earlier question rattles around inside R2’s dome for a while.
Those old astromechs must just take a while to boot up again.
That's a far less satisfying explanation than anything involving the Force, or R2-D2 detecting the Force in Rey – but that's the answer from the filmmakers.
It seems like a coincidence to us because it occurs straight after the main events of the film end.
We don’t know how much time surpasses between the destruction of Starkiller Base and R2-D2’s awakening.
If he really was in low power mode, he might have sat there for days before finally realising what BB-8 was trying to say.
(PS
When I read this the first time, I expected the paragraph starting “The director acknowledges” to continue “that R2-D2’s awakening is a huge deus ex machina”, but apparently not.)
scifi.stackexchange.com/users/3567/alexwlchan
I think, and this is just a guess, that R2 was activated by Luke using the Force.
It has been shown before that in some ways the Force is used over great distances, like feeling when a planet is exploded.
My theory is that Luke deliberately put the map in R2 and that he was going to activate it when he wanted to be found.
It was very clear that Luke didn't want to be found
and I think that if he still didn't want to be found now he could hide easily.
But Luke now either sensed the Starkiller station being destroyed, Han dying or Rey becoming more Force-sensitive and in need of training or maybe a combination of both and therefore decided that he didn't want to hide anymore
scifi.stackexchange.com/users/28420/Ivo Beckers
My guess is Rey is
Luke Skywalker’s child and R2-D2 sensed “the Force” in her.
Or at least somehow recognized her visually or by sound when she was nearby.
C-3PO makes it very clear that R2-D2 has been in self-imposed “low power mode” (aka: deep droid depression) since Luke went into hiding.
Heck, R2-D2 is covered with a sheet when BB-8 first finds him.
Then R2-D2 suddenly “snaps out of it” when who arrives?
Rey!
She’s
Luke’s daughter.
R2-D2
’s choice to go into “low power mode” and cover himself with a sheet all day was his choice.
And when Rey shows up he senses something familiar and snaps back to life!
Hooray!
And past that… Lo and behold…
The darn droid has a HUGE map of the galaxy (?) including areas that are apparently uncharted?
Or perhaps BB-8’s missing piece was the only uncharted part the galaxy?
Where did R2-D2 get those chunks from?
It would have made more sense if Rey salvaged some data storage device from the wreckage on Jakku and then Rebellion analysts were able to recover data from that.
Which is also all to say
… You are kidding me that data such as maps—or plans to the Death Star—can’t be copied as easily as we copy data today.
Unless the devices that contain that data in the Star Wars universe have some kind of encryption or biometrics or something?
scifi.stackexchange.com/users/14850/Giacomo1968
We can only guess.
Here is what I think happened.
Kylo Ren said that they had the missing part of the map to find Luke.
That they found it on some information from the Empire.
So when the planet that housed Starkiller base started to explode, maybe they started transferring all their data to other place and R2-D2 was able to intercept the map data from them.
Then since R2-D2 had found some way to get to his master, he activated.
They did mention that he was in Low Power Mode or something like that.
It's just a guess.
It was not explained how R2-D2 got that info in the movie.
scifi.stackexchange.com/users/57244/Alessandro Sanfilippo
Another possibility Earlier in the movie BB-8 mentions that the remainder of the map might be in R2-D2s memory banks.
It seemed to imply that the map had been erased or deleted somehow.
Is it at all possible that his low power mode was not just because of droid depression, but instead he was trying to recover that map from his memory and it required all his attention.
Low power mode meant he wasn't receiving any new information to overwrite any part of his memory.
It fits in with the loyal droid idea, that he would devote all his time and energy to finding his master.
scifi.stackexchange.com/users/56685/G.James
During  The Force Awakens , BB-8 tries to wake up R2-D2, but is unsuccessful.  At the end of the movie, R2-D2 wakes up.  I didn't catch anything really explaining why he would activate just at that time. So, what did happen to make him wake up?
What made R2-D2 reactivate in “The Force Awakens?”
scifi.stackexchange.com
<star-wars><the-force-awakens><droids>
scifi.stackexchange.com/questions/110887
scifi.stackexchange.com/users/55735/Relix
It's not exactly clear what caused R2-D2 to wake up at this particular moment and any answer would be speculative. It could be that the force awakened him or it could be that he was in a self-controlled low-power mode and would have awoken at some point in any case. The director has acknowledge that this was put at the end of the story for emotional storytelling purposes. The most compelling explanation is from the film's writers who said it was a plot device with no real explanation to back it up, but fans have nonetheless come up with a number of possible explanations.
The film's writers themselves say that the idea was to have a slow wakening up for R2-D2 for emotional storytelling reasons. R2 may have been activated by Luke using the Force. R2 was possibly in a low power mode and activated once he saw a way of getting the vital map data to his master Perhaps R2 was non-responsive for so long because he needed all of his power to recover the important map data needed by his master.