Ford later described the thematic necessity of the brutality as part of Thor's character arc for Avengers: Endgame, explaining that "part of the story is Thor dealing with something he really shouldn't maybe have done."
When Thor loses his temper, it's usually a mistake, and that's been in several plot points of all the movies in which he's featured. His actions in Endgame were the culmination of everything he's done and been up until that point: a kind, righteous, and impulsive first son overburdened by everyone else's (and his own) expectations, brought to the doorstep of ultimate failure. Slaughtering Thanos in such an act of overkill was a compounding of failure, because even though there was no taking back the universe-halving action of Thanos' Infinity Gauntlet, empty murder isn't a hero's best method of coping, either.
It's because Thor chose to do what he did to Thanos in Avengers: Endgame, on top of failing literally half the universe in the previous movie, that the God of Thunder completely falls apart in the following five years. "You should have gone for the head" was Thanos' taunt in Infinity War — and when Thor is asked why he just chopped off Thanos' head mid-sentence, he responds, "I went for the head." Thor allowed himself to be defined by the mistake he made in Infinity War, and by Thanos, to the very last moment. That would destroy anybody's morale and sense of self once the moment caught up with them.