How do the tripods with the flames help teach a lesson in The Masque of the Red Death?
The fire of the tripods in The Masque of the Red Death represents life and hope, which is a normal symbolic meaning for fire in many stories, not just this one. The Masque was meant to distract Prince Prospero and his party guests from the horror of the Red Death that was going on outside of the walls of their fortress, and the tripods illuminating the rooms through the stained glass windows were shining hope into the rooms as well as light - hope that the Red Death stays out of their fortress and does not kill them.
This is shown further at the end, when the Red Death kills all the people present at the party. When everyone is dead, the fires in the tripods go out; there is no more light, there is no more hope for safety from the fatal disease, and there is no more life.