(This is answer is entirely theory and conjecture, and as such devoid of sources. If another answer comes along that does have sources, please upvote that past this one)
Luke's knowledge of Darth Sidious and the rise of the Galactic Empire:
With the death of the Sith at the end of Return of the Jedi the Force was once again easily accessible and in balance. This shows itself, among other things, by having a whole parade of force ghosts showing up for the final scene of the film.
With that established it is far from a stretch to assume that Luke had further exchanges with force ghosts of the Jedi that he knew, Obi-Wan and Yoda, who both had first hand contact with the rise of the empire and the fall of the order.
Rey's knowledge of the particulars of Darth Vader's fate:
Luke had a semi-public funeral for his father back on Endor, giving an opportunity for the core of that story, Luke having saved Vader, to be woven into the legend. Actual events turning into legend is definitely a theme of The Last Jedi, based primarily on the epilogue, and Return of the Jedi also establishes this with C3-PO telling the tales of the Rebel Alliance to the ewoks.
Of course one could argue that that's only enough for the broad strokes, that it was improbable that the legend happened to exactly cover the truth of the events (and discarding the possibility that the films we all love ARE the legends). Additional details, especially about the emotional state of Luke, could have been learned through the Force as Rey interacted with Luke.
There is precedent from The Force Awakens too where Rey learns a lot about Kylo Ren's emotional state and fears despite his resistance.