There was once a beggar who had tried many ways to get money. At last he thought he would pretend to be dumb. Now one day a gentleman who had known the beggar by sight passed by. He went up to the beggar and asked him suddenly :“How long have you been dumb?” The beggar was taken by surprise and quite forgot that he was ‘dumb.’ He answered quickly :“Oh, ever since I was born,sir.”
The underlined part, how about "knew the beggar by sight"? Is it also allowable? Or does it have to be "knew" to be grammatically correct?
"Had known the beggar by sight" is grammatically correct and so is "knew the beggar by sight."
The difference is in when and for how long he knew the beggar:
"Knew" is the past form of "to know" so when you say "he knew the beggar" it means that he knew him at some point in the past for an unspecified amount of time.
"Had known" is a past participle. When you say "he had known the beggar" it also means that he knew the beggar in the past, but the meaning is a little different from when you use the simple past form. It implies that the action (in this case "knowing") is completed. Maybe the man knew the beggar before, but he has not known for the last three years.
So both of your suggestions are grammatically correct, but since the action of knowing seems to be ongoing in this case, I would use the simple past form.