Bro. Doucette’s replay is indeed a good one. I can add a bit, since I am myself an organist and regularly performed that function for my lodge back in the days when we met in a building that had an organ in every lodge (and York Rite) room.
Firstly, why music at all? I don’t have to inform a musician that until fairly recent times (i.e., before gramophones, radio and TV) the making of music together was probably the chief way in which people, especially families and other congenial groups of people, entertained themselves. There wasn’t any other way. Music as a supplement to public worship also has a very long and glorious history. So it should not be surprising that early in the history of modern Masonry, music began to be used to accompany the lodge work. When reasonably well done, it really adds to the ceremonies. I can’t count the number of times someone who has heard music in lodge for the first time has told me what a difference it makes. Unfortunately, it’s rather rare these days. The organist must, of course, be a Mason to work in a tiled lodge, and the number of organists who are Masons has fallen off even more than the general population, since there weren’t legions of them to begin with. Also, most of the old pipe organs which were once installed in lodge rooms, not being used much, have not been maintained and thus deteriorated, leading to their being discarded and not replaced because of the cost. Of course, electronic instruments are available, but they aren’t often obtained, I’m not sure why.
Beginning in the 18th century, after lodges started meeting in their own dedicated facilities instead of on the upper floor of a tavern, they frequently had a small pipe organ installed to provide music, this being preferred to the then-available alternatives of the harpsichord, clavichord or fortepiano. A small one-manual organ was not then terribly expensive and a lodge member would act as organist, with another member working the wind pump, and most of the members knew how to sing (and more than a few were likely to be very good singers). Mozart wrote several pieces of music to accompany the work for his lodge and presumably played them. A couple of them have survived; details can be found if you hunt around for them. Going forward a century, J.P. Sousa, who was a Knight Templar and a Shriner, wrote two marches for the KT and, I believe, one for the Shriners. Again, I don’t have the details handy, but you can find them.
As to what is played in modern times, it depends on the organist and the instrument. I once attended a Spanish lodge in NYC to see the 3rd Deg. conferred in the Grand Lodge room. The organist (whose name, improbably, was Leo Heidelberg) entertained everyone by playing show tunes before the work started. His rendition of Hello Dolly was outstanding. Of course, he played serious music once the lodge opened. That’s where the lighter music you mention comes in. For the lodge opening/closing and the degree work, the organist will play appropriate mood music, often classical pieces, or hymns. Back in the day, I used to play, and the members used to sing, Nearer my God to Thee, Pleyel’s hymn, and a special piece called High Twelve Has Come at the appropriate places during the 3rd Degree. In the Knight Templar ritual for the Order of the Red Cross, there is a rubric stating that the line Thus shall it be done to the man whom the King delighteth to honour is to be said or sung. It used to be sung in my Commandery, as I found in the organ bench a very old hand-written sheet of paper with the music for this line. I have in my possession an booklet published in 1909 in 4-part harmony for men’s voices, of music for the Royal Arch Chapter, some of which is actually required (but in practice never used) by the Maryland RA ritual.
Masonic music is a really big area and an interesting field of research for the serious musician.