The long-serving prime minister leaves behind a mixed legacy of political achievement and scandals after announcing his resignation.