Was Albus Dumbledore, the former Headmaster of Hogwarts School of Witchcraft and Wizardry, a hero or a villain? With his 25th death anniversary approaching fast on June 30, 2022, it's probably the right time to have a gentleman's discussion on the matter.
In order to make an answer out of it, first we have to take into account what the terms 'hero' and 'villain' actually mean in modern literature.
Hero: The principal character of a literary work.
Villain: A character whose evil actions or motives are important to the plot.
What we can gather from these definitions is that, even if Dumbledore was not a hero, he was not a villain either. He was not the main character of the Harry Potter series, and was not even physically present in the last instalment Deathly Hallows, he was by no means the character whose evil actions or motives put the central character Harry in trouble throughout the series. It was Voldemort who is to be blamed for that.
Besides the literal meaning, it also depends a lot on how the author tried to portray a character through her writing, and where exactly were her intentions placed.
We know JK Rowling wrote this series basically for kids (before realising afterwards that it's actually meant for young-adults) and as such, she tried to keep it as simple as possible. She clearly tried to build a positive character to accompany Harry from the onset of the story; someone he can rely on at any circumstances.
In the debut book Philosopher's Stone, we see that Dumbledore sends Hagrid to rescue Harry and bring him to the Privet Drive to stay with the Dursleys and be like a muggle until he is old enough to go to magic school Hogwarts. First we wonder why Dumbledore does that despite knowing how cruel the Dursleys can be.
We get the answer later that Harry's mother had created a magical, sacrificial protection for his infant son, and it would remain alive and effective only if Harry — till the age of seventeen — lived with someone her mother had blood ties with. So apparently Dumbledore's sole motive was to protect Harry by creating a bond of blood.
In the next five parts till Half Blood Prince, Dumbledore is always there for Harry to come to the rescue when Harry is in Hogwarts or anywhere outside Privet Drive. Dumbledore is like the old man Harry needed as a father figure. And then he also chooses Snape to sacrifice his life to, so that Harry can get hold of the Elder wand as well as take the responsibility of looking after Harry.
At the end of the series, we see Harry naming one of his sons after both Dumbledore and Snape. Why did Rowling make Harry do that? Only logical reason is that she glorified both characters for one last time.
No denying the fact that Rowling created a very complicated character like Snape which gets a big twist just before the climax and suddenly becomes a good guy from a seemingly bad one. However, it does not necessarily mean Rowling would keep Dumbledore's character a mystery as well, even after the completion of the story proper. All she wanted us to believe was that Dumbledore was a hero, or at least a good person, and so we have to live with that.
But yes, we also must concede that Dumbledore's character was not a paragon of morality. He had made many mistakes in his youth, made several wrong decisions, especially with his family, kept a lot of secrets regarding his true identity and background, and perhaps once upon a time he had also lusted for power.
If we want to consider Dumbledore a villain, it also does change the whole complexion of the series. Snape's actions were well developed from the beginning, and made sense following the 'Great Revelation'. But Dumbledore's were always nebulous.
It also opens up the never-ending discussion of whether Voldemort was really the villain or the victim. If he was the latter, then doesn't it also make Harry a villain for killing him even after several attempts to go inside his brain and fully understand his feelings and motives? And when it does so, it just goes completely out of our control. We no more know who is right and who is wrong, who is good and who is bad. But no matter how far imagination can run riot in the wizarding world of Rowling, it just can't be this complicated.
So brushing aside all the speculations that Dumbledore was probably a villain, we must come to terms with the fact that he was indeed a hero.