The original intention of this sentence is positive, which is a metaphor for a person's temperament of leading an honest and clean life.
But whether any sentence is positive or negative, we should distinguish it according to the specific situation.
For example, some people live in a group, can't adapt to the environment, have difficulty communicating with people around them, don't like something, can't integrate into the group, and pretend to be lofty. In this case, some people may say that someone is "out of the mud but not stained, not a demon", then this sentence means ridicule at this time, and the main idea is innuendo, which is of course derogatory.