Movies that involve the infinity stones:
Captain America: The First Avenger
Avengers
Thor: The Dark World
Guardians of the Galaxy
Avengers: Age of Ultron
Dr. Strange
Avengers: Infinity War
Movies that give important background to the major aspects/ characters of the movie:
Iron Man
Captain America: Civil War
Thor: Ragnarok
Ant-man and the Wasp
Other movies will provide greater character development and explain a lot of other minor aspects, but those are probably the most important ones to watch. If you had to just pick 5 of them, I'd choose Avengers 1, 2, and 3, GOTG, and Captain America: Civil War.