The keyword here is devadasi.
Devadasis were female artistes who served the presiding deity of a temple. Until the British rule, temples were an important economic and social centre of every village and town in India, and devadasis were held in high prestige. They did not marry since they were considered to be wedded to the Lord in the form that He held in the temple. Apart from taking care of the temple duties, they would also perform music and dance for their "husband", the deity in the temple. As such, they held an important place in preserving and carrying the traditions of Indian classical music and dance.
During the British rule, devadasis were systematically shunned by equating them with prostitutes. The public perception of devadasis was successfully changed by the colonizers, and the average person came to believe that the word devadasi is a synonym for a person of low morals, one who sings and dances for the pleasure of other people and for the sake of money. Today, temples are no longer considered to be economic or social centres, and the devadasi institution has vanished. The last devadasi, associated to the Puri Jagannath temple in Odisha, passed away a few years ago in 2015.
Khushwant Singh's grandmother considered music and dance as something that was practiced only by devadasis, and so she associated these with "harlots", and also "beggars" because it is a common sight (even today) to see people in India begging on the streets — and in second class train compartments, in particular — by singing devotional or other popular songs. "Gentlefolk" refers to those people who have had a good or moral upbringing.
To be sure, the purpose behind the music influences these associations in the grandmother's mind. Traditional songs would be sung in temples, this much is true, but such devotional music would be sung or chanted for the Lord, and maybe in a group. So, the grandmother is not opposed to all music; for instance, she hums some prayers as a part of her morning routine:
She used to wake me up in the morning and get me
ready for school. She said her morning prayer in a monotonous
sing-song while she bathed and dressed me in the hope that I
would listen and get to know it by heart; I listened because I
loved her voice but never bothered to learn it.
When the author's school was attached to the temple, some of the lessons involved learning the morning prayers, which were also chanted or sung:
My grandmother always went to school with me because
the school was attached to the temple. The priest taught us
the alphabet and the morning prayer. While the children sat in
rows on either side of the verandah singing the alphabet or the
prayer in a chorus, my grandmother sat inside reading the
scriptures.
But, singing privately for an audience — that would be a strict no-no.
The incident with the music lessons occurs after the "turning point" in the author's relationship with his grandmother, which happened when they shifted to the city and the author was enrolled in an English school. The lessons and traditions taught in the English school were generally foreign to the grandmother and they made her uncomfortable:
I would tell her English words and little things of
western science and learning, the law of gravity, Archimedes’
Principle, the world being round, etc. This made her unhappy.
She could not help me with my lessons. She did not believe in
the things they taught at the English school and was distressed
that there was no teaching about God and the scriptures.
Immediately following this is the description of the music lessons quoted in the question. So, the grandmother's problem with the music lessons should be seen in the context of her discomfort with the unfamiliar lessons and traditions taught in the English school. For example, one can also be sure that the music that the author was being taught in the English school was very different from the traditional prayers that the grandmother knew.
So, her cognitive dissonance, if you will, following the "turning point" would have increased her tendency to associate that sort of music lessons with the other "improper" music-related activities that she knew of, namely that of the devadasis.