Stings and acid can do different things to different animals. Harvester ants have venom that is specifically designed to be painful and harmful to mammals. I believe the purpose of this was to deal with the small rodents that try to raid their nests of seeds.
But beyond being targeted to mammals this sting can also be lethal to other invertebrates. You don't need to feel pain from an injury or attack of some kind in order to be injured or killed by that attack.
There is a rare disorder than some people have where they are entirely incapable of feeling pain of any kind. You could break their ribs and they wouldn't be able to feel it. Does this mean that because they can't feel the injury, being physically damaged is harmless to them? Not at all. In fact, these people actually have a significantly higher risk of dying than normal people because they're unable to detect injuries that they get unless they happen to be paying attention to the affected area as it happens. They also tend not to have the unconscious injury avoidance techniques that most people develop as children because they never really feel the consequences of being injured except abstractly.
You are thinking of injury and injured-behavior as being attached exclusively to pain because that's what humans and other vertebrates associate with being injured, but the actual problem with being injured is that injuries can kill you. You don't need a "brain" complicated enough to feel pain in order to try to avoid damaging environmental factors, and you certainly don't need a brain to die of sufficiently damaging environmental factors. See Sea Sponges and bacteria for this.