It is because he was successful in conquering a lot of land and preventing attacks. He also put out a lot of reforms and reduced corruption, and in the eyes of the people it was the best they had.
The main factors are what they accomplished during their reign and also if they had any mistakes towards the end. People tend to remember the most recent thing they did and if it was good or not