His last words were that he had to do what was right despite knowing who Thomas was and that no one ever understood what he saw during the

People seem to forget that Gally came back to the Glade after being humiliated to warn the Gladers about how the grievers were going to take one of them a night until it was over and then sacrificed himself to the grievers so no one else would have to be taken that night.