What actually happens during anting is easy to observe and record, especially as many birds will display anting activity in captivity if offered ants. A more difficult question to answer is why. In truth nobody seems really sure what birds get out of anting. People have theorised that the ants help rid the birds of pests like feather mites and louse flies, other theories suggest that the anting is just a way of getting the ant to discharge its store of formic acid before eating it. The trouble with this idea is that it doesn't explain passive anting.
Scientific evidence supporting the pest control theory is hard to find.
However, it is known that ants are only eaten after they have discharged all of their acid. It is not unreasonable to assume that active anting as we see it today evolved from a detoxifying action to make ants edible but gave the added benefit of pest control to some extent. Perhaps related to anting, but even more bizarre is 'smoke bathing'. Birds such as Rooks have been observed standing on smoking chimneys with their wings spread open in a similar posture to some birds when anting. Birds have also been seen to use smoking cigarette butts for anting.