I can only think of three reasons people can justify grading: motivating, ranking & sorting and providing feedback. Each can be rationalized with the best of intentions, but each suffers ultimately from grading's unavoidable, inherent flaws.
If school's only purpose was to sort children into the proper categories... if our primary objective was to herd children like cattle into their proper pens, than grading and testing are the tools for the trade.
But sorting children like they were cattle, or ranking them as if they were mere contestants in a race is not the same as working with them to become kind, caring, competent citizens.
Even if teachers some how developed the perfect grading system that reliably ranked and sorted children with impeccable validity, placing the proper label on each child as if they were a slab of meat ready to go to market, it is very likely we could give the politicians everything they could ever want while providing the children nothing they really need.
Because ranking and sorting has no place in education, grades have no place in learning.