Alan Dean Foster's novelization explains it, kinda:
Following in the Wookiee’s wake, an exhausted Rey found herself greeted by a cheering crowd. Leia Organa was in the forefront, accompanied by a pair of droids. Rey recognized BB-8 immediately, and wondered at the identity of the gleaming golden protocol droid at his side. Instinctively, she headed toward Leia.
No general now, Leia took the young girl’s face in her hands. Though brokenhearted at the deaths of Han and so many brave pilots, Leia was grateful for the deliverance of the Resistance. In spite of the presence of the crowd that was looking on, the two women embraced without embarrassment or hesitation. Then, with tears falling, they moved inside.
Rey headed for Leia on instinct. The fact that she was with BB-8 - her friend - probably helped.
Leia knew who Rey was, of course, and was glad she was saved from almost certain death when the Starkiller base was destroyed (until Poe disobeyed orders and saved them)
They were both emotionally exausted and in need of a hug.
It may sounds overly stereotypical, but it's a typically big comfort thing for many women, so makes sense to put it in the film. It's a powerful visual and emotional statement of comfort and closeness.
And the WGA script just confuses things more:
The two women move for each other. And Leia takes Rey's
face in her hands. Despite her heartbreak, she is grateful.
She embraces Rey. A mother's embrace.
Problem is, this could mean simply "she embraced Rey like a mother would", or it COULD mean "She's Rey's mother". So not too much incontrovertible information added.