I would not consider "Q" as a villain, rather a bored super being who desperately tries to find something funny and entertaining to spend his eternal life. After spending an eternity and using absolute powers, the "humane" notion becomes necessarily distorted and makes him capable of unimaginable acts abuse. But, from what we have learned about him, when he did something wrong, somehow was convinced by the humans to remedy the situation and reverse the damage. And, occasionally, he was actually funny.