My informant had a personal experience with this folk belief while attending her grandmother’s funeral in Thailand. She and the other funeral-goers were kneeling in prayer in front of the Buddhist temple where the funeral was being held, when she noticed a black butterfly fly over her grandmother’s coffin as the monks chanted a sutra to help the soul pass on.
When my informant mentioned the butterfly to an aunt afterwards, the aunt told her that butterflies are containers for souls, and that they carry souls away. The timing of the butterfly’s flight, as well as the fact that she’d never seen a butterfly in Thailand before, convinced my informant of the validity of this folk belief.
My informant suggested that it may be comforting to someone mourning a death to equate their loved one, and maybe death itself, with a butterfly, which is almost universally considered to be beautiful and graceful.
The main religion in Thailand is Buddhism, which rejects the idea of an unchanging self or soul, and so the soul’s flight in the butterfly could be considered the luminal stage between death in one body and reincarnation in the next. Also, while human/alive, we can’t fly—it could be exciting to think that in death, we are able to rise beyond the limitations of our past human bodies.