Jesus says these words after the Pharisees accused Him of casting out demons by the power of the prince of demons. That is, according to them, an evil power serves as the cause of a good deed. By this short parable Jesus asserts: that does not happen. Craftiness and dishonesty speak in the Pharisees; they "adjust" reality to a conclusion set in advance. For them the evaluation of the fact has already been determined even before the fact. In addition, they are ready to change the criterion for distinguishing good and evil depending on circumstances and usefulness.
Christ shows that by accepting such logic they, and at times we too, themselves come under the power of the one who is called the father of lies. The criteria for distinguishing good and evil must be unshakable, for they come from God; therefore they must apply equally both to the "tree" and to the "fruit." And any situation must be evaluated on the basis of facts, the "fruit," and not on whether we like or dislike the "tree."