It's just what they do. Other species of birds, too. If they are displeased by something, how else can they relay that message to us?
My Scarlett takes it one step further. If I'm holding him and an unknown visitor comes to my home, he'll displace a bite of displeasure onto me. Ouch! Can't figure out if he's trying to warn me of perceived danger or that he's biting because he can't reach any of the visitor's appendages.