When the pendulum swings in air, it does work against the friction of the air to sustain swinging. In the process, some of the other energy is dissipated and converted into thermal energy. This makes the pendulum to lose some of its mechanical energy. As it starts losing energy, it will come to rest when all its mechanical energy is dissipated