Miss Trunchbull seems to reject and hate anything remotely feminine, whether that’s a very feminine hairstyle on girls or longer (and, per the novel, more feminine) hair on boys—she has some internalized misogyny going on here. Lifting Rupert by his hair, just for getting an answer wrong, gives Miss Trunchbull lots of power over the class. It shows every child to be afraid—and nobody performs well when they’re afraid. So she’s setting the entire class up to perform poorly, possibly so she can justify abusing them further.