The ability for one powerful Force user to communicate directly with another Force user (especially one with whom one shares a personal connection) was shown in Star Wars: The Empires Strike Back when Vader speaks briefly to Luke.
"Luke, It is your dest..tiny"
Last Jedi Director Rian Johnson spoke to both the in-universe methodology and also the filmmaking rationale in an interview.
“It was always through the demands of the story. With the Force
connections between Rey and Kylo I thought, ‘OK, I need to get these
two talking. But if I put them face to face they’re going to either
fight, or one of them has to be tied up.’ So I knew I wanted them to
talk, and to talk enough to where we could go from ‘I hate you,’ to
her being forced to actually engage with him. That’s where the idea of
these ‘Force connections’ came from, which is kind of a new thing.
It’s a little bit of a riff on what happens with Vader and Luke at the
end of ‘The Empire Strikes Back,’ but it’s entirely new in some
regards.”
The Last Jedi: Rian Johnson Explains Kylo/Rey Force Connection
Snoke claims that he did this intentionally, in order to lure Rey into his clutches.
Snoke: Young fool. It was I who bridged your minds