It's not easy to find that fine line. Probably the most important quality is to lead by example. No one will trust a moderator, who is not representing the values of the community. It also builds respect, and people generally react better if they get told off by someone who is always showing a good example.
The other important quality would be a sound judgement, being able to decide if something is straight against the code of conduct or is it just a miscommunication / misunderstanding /accident and deserves the benefit of doubt.
And when it comes to the latter it is helpful to have someone who knows the community and how people talk or behave in general, because it will be an advantage when they have to approach and talk to members. For example if you regularly engage with members, it will be easy to learn who might not have English as their first language and an argument might have broken out because of language barrier.
Of course if the moderator is an active community member as well they will build close friendships with other members. If a situation would require they would have to be able to call on a fellow moderator and say "hey it's better if you handle this, because I might not be able to make a fair decision here."
And last but not least, something what 18 years of customer service taught me: treat people with respect, even if they might not deserve it.