The context is Jesus contrasting calling a brother a fool with the action of murder.
“You have heard that it was said to those of old, ‘You shall not murder; and whoever murders will be liable to judgment.’”
Murder, the physical ending of life is contrasted with anger, insults and denigration (“you fool”).
“But I say to you that everyone who is angry with his brother will be liable to judgment; whoever insults his brother will be liable to the council; and whoever says, ‘You fool!’ will be liable to the hell of fire.”
Jesus doesn’t/didn’t have murderous anger in His heart towards those He called fools/foolish. He was making a statement of fact. As was Paul
“O foolish Galatians! Who has bewitched you? It was before your eyes that Jesus Christ was publicly portrayed as crucified.”
Paul wasn’t denigrating the Galatians, belittling them, criticizing in a derogatory manner, he was pointing out to the Galatians that they have been fooled and/or were acting foolish because they ought to know better.
The intent in Matthew5:22 with regards to the statement “you fool” wasn’t that you fool should never be used but that if used in a derogatory, denigrating, disparaging manner that person, whoever they may be, anyone including Jesus if He were to say you fool in that way would be liable to hell fire. Whereas Jesus doesn’t use the phrase in that way.
“The Pharisee was astonished to see that he did not first wash before dinner. And the Lord said to him, “Now you Pharisees cleanse the outside of the cup and of the dish, but inside you are full of greed and wickedness. You fools! Did not he who made the outside make the inside also?”
He is calling them out on their inconsistencies, short-sightedness and calling them fools for not thinking it through before asking their trick question.
But it was not said derogatorily. He is just pointing out their inconsistencies. But no one can accuse Jesus as being murderous and angry in His statement. He is just picking apart their argument and letting them know they are fools for asking a foolish/stupid question assuming no one could see what was in their hearts.
They thought themselves righteous because outwardly they looked the part but Jesus is telling them they didn’t fool anyone but themselves because God see both the I side and the outside
Now you Pharisees cleanse the outside of the cup and of the dish, but inside you are full of greed and wickedness
And He explains that the Creator (Jesus) can see not only the outside but the inside. They looked like fools for trying to hide what God could clearly see was on the inside
Did not he who made the outside make the inside also?
This was an accurate description of their foolishness, trying to trick God by putting on a facade which God could see right through, making them proper fools, not as an insult but as a matter of fact.