Rhaegar Targaryen is arguably the most important Game of Thrones character, and until the season seven finale, we had never even seen him. His death marks the end of a long and complicated rebellion full of forbidden love and a plethora of fighting and death. If you're wondering how or why he died, or perhaps you've forgotten, we are here to help, because he's definitely an important piece of the Westeros puzzle.
Rhaegar is the eldest son of "Mad" King Aerys II, making him heir to the Iron Throne and Daenerys's oldest brother. The Targaryens are allies with the Lannisters way back when at this time, and Cersei always thought she might marry Rhaegar, but the two families' peace falls apart when the Mad King instead marries Rhaegar to Elia Martell of Dorne, with whom he has two children. But everything really falls apart in the Seven Kingdoms when Rhaegar sees Lyanna Stark at the Tourney of Harrenhal.
Rhaegar is so taken with Ned Stark's sister (who was also Robert Baratheon's betrothed) that when he wins the tournament, he gives the victor's wreath to Lyanna instead of his wife. Several months later, Rhaegar allegedly abducts Lyanna, but we now know from season six that she goes with him of her own free will — and they secretly get married, as we found out in Game of Thrones' season seven episode "Eastwatch," though the Game of Thrones characters all think Lyanna was the victim of kidnap and assault.
This controversy is what spurs Robert Baratheon's rebellion, backed by the great Houses Arryn, Greyjoy, Stark, and Tully. The Lannisters even eventually join the rebellion after the Battle of the Trident, which is where Robert kills Rhaegar with his war hammer.
This defeat is the beginning of the end of the Targaryens, which is why the Lannisters finally join Robert's side — like true Lannisters, they wait to see which side emerges victorious before they make a choice.
After Rhaegar's death, the Lannisters sack King's Landing. Jaime kills the Mad King (thus his nickname, Kingslayer), bannerman Ser Gregor Clegane (aka The Mountain) kills Elia Martell and Rhaegar's two children, and the rebellion is complete. Tywin Lannister marries his daughter Cersei to Robert, and King Robert takes the throne.
However, Rhaegar's line lives on. While all of this was happening during the rebellion, Rhaegar sends his pregnant new wife, Lyanna, to the Tower of Joy under the watch of Kingsguard members Ser Arthur Dayne and Ser Gerold Hightower. Eddard tracks his sister there and is present when she gives birth to Rhaegar's son and heir. Ned passes the baby boy off as his own bastard because Lyanna asks him to protect the baby from King Robert (who would surely kill Rhaegar's heir if he knew the truth), and that's how Jon Snow comes to be part of the Stark family.