The two canonical student views of grading during clerkships are the "learn a lot, get along, work hard and you'll get honors" sunshine view, and the "it's all arbitrary, and the residents screw you" dark cloud view. (Though that's obviously an unfair characterization of irlandsea's post above.)
In my opinion, the truth is somewhere in between. Here's my model of how clerkship grading works.
In general, I think most people actually can tell good medical students from mediocre ones; it's mostly a matter of the confidence the student projects. But good students also are the ones who do lots of learning, help their teammates, "go the extra mile", and all that. And the shelf exam adds a quantitative element as well. So that combination (confidence, enthusiasm, exam performance) sort of sets the range you're working in. If you do well in all of those, you're in the Honors/High Pass range; if you do most, you're in the Honors/High Pass/Pass range, and if you do almost none, you're in the High Pass/Pass range.
After that, weird interpersonal stuff kind of sets the final grade. If you're in a H/HP/P range, and you really got along great with an attending who actually communicates their enthusiasm for you to the clerkship director, you'll get the Honors. On the other hand, if you're in the H/HP range and you didn't get along well with the clerkship director, for whatever reason, you'll get the HP.
Yes, there is a definite element of injustice in this. I'd bet that virtually every medical student has a anecdote about grading that causes them to grind their teeth whenever they think about it (I know I do). But when you're actually on duty, you have to try and do the things you can actually control, which are the "Go team! Rah rah!" things already mentioned. And that's easier if you pretend you don't know about the arbitrariness.
It's a maddeningly imperfect system. But I think most of the people in the system are trying to make it work out right. You just have to do your best and have faith in that.