Harry knew he was supposed to save Ron because throughout the books, he hinted many times that he preferred Ron as a friend over Hermione. For example, in GoF: > "Harry liked Hermione very much, but she just wasn't the same as Ron. There was much less laughter and a lot more hanging around in the library when Hermione was your best friend." -Harry Potter and the Goblet of Fire, Chapter 19: The Hungarian Horntail To sum this up, in terms of friends, Harry chose Ron over Hermione. He also knew that Viktor had taken Hermione to the Yule Ball. > "His eyes fell instead on the girl next to Krum... It was Hermione." -Harry Potter and the Goblet of Fire, Chapter 23: The Yule Ball And Harry knew that Cedric took Cho to the Yule Ball(giving that he had also asked Cho out). > "'Oh—Cedric,' she said. 'Cedric Diggory.'" -Harry Potter and the Goblet of Fire, Chapter 22: The Unexpected Task And Harry did not know Gabrielle before the task. > "Ron was tied between Hermione and Cho Chang. There was also a girl who looked no older than eight..." Harry Potter and the Goblet of Fire, Chapter 26: The Second Task Every other hostage was narrated by name except for Gabrielle. So, Harry knew to choose Ron.