Your class and the class next door have different numbers of students who took the test. Comparing raw frequency (headcount) alone always makes the bigger class look better, but switching to relative frequency — each class's share of its own total — makes for a fair comparison.
Relative frequency = (that class's frequency) ÷ (the total frequency). It's the "share" each class takes up of the whole. That's why relative frequencies always add up to 1 (=100%).
Press the "Compare by frequency" button below and you compare raw headcounts; press "Compare by relative frequency" and you compare shares instead. See for yourself which one gives a fairer comparison when the two classes have different numbers of students.