In her first year at Hogwarts, Luna tried to be like the other girls.
She tried to look and dress like her peers, tried to talk like them, tried to do the same things as them in lessons. She was tired of having no friends because her father was strange and she was strange. She wanted to be a normal girl for once.
And it was exhausting.
Luna had to spend every moment of every day thinking about how she could make herself seem like the others. She had to concentrate on things like the way she walked and the animals she mentioned, or else she would be given the funny looks that she had always received before.
And in the end, the other girls still went off without her and talked behind her back about what a strange girl Luna Lovegood was. And the more Luna tried to be like them, to be someone they could understand, the more their insults stung.
Until she couldn't stand it anymore.
On her first day of her second year, Luna wore the necklace made out of butterbeer corks that she had made herself. She sat alone in a compartment on the train and read The Quibbler, which she had made sure to keep hidden last year. When she saw Wrackspurts fluttering around Ginny Weasley's head, she batted them away for her instead of letting them worm into her ears the way she had done in the first year, though Ginny protested and batted her away.
The insults came to Luna's face now – Looney Lovegood became her name to everyone except her Professors – but they didn't hurt as much anymore. She could speak up against them if she needed to (she was more than happy to tear into anyone who insulted her father, for example), but more often, she could just smile dreamily at them and go back to reading.
When she didn't try to act like the other students, Luna had a weapon to use to defend herself against them. She could step into a different world, and she could tell them in complete honesty that she didn't care what they thought of her, because she wasn't trying to be like them.
Being different than them made it harder for them to hurt her.