Most plants have developed some way of avoiding being eaten. You only have to think of stinging nettles, roses or brambles to be painfully reminded that any creatures interfering with them can be stung or scratched quite severely.
Many species of plants produce natural insecticides which keep unwanted insects at bay, but some tropical palms and acacias have enlisted the help of certain species of insect to act as protectors. These plants have colonies of insects living among their leaves and, should any other animal attempt to eat the leaves, the ants drive them off. In reality the ants are just protecting their home as they would any other sport of nest, but it gives the plant a very useful form of protection, too.