It is difficult to say no, but if done with grace and tact, it can be quite productive for the applicant in the 'long run.' This can be an opportunity for growth and a 'reality check' for the applicant. If you feel you can't write a good letter, it is vital for the applicant to clearly hear why. If it is lack of knowledge, perhaps a conversation could give you enough information, or the time frame might be negotiable. You need to be honest with the applicant about your reasons. You may not know the applicant well enough, you may not have time to write it by the time the applicant needs it, you may not feel you could say good things about the applicant, etc.
There are several reasons to refuse a request to write a letter of recommendation. When not to write a letter of recommendation. The selection committee relies on these letters to assist in making a final decision. The letter of recommendation should give a picture of the candidate's personal characteristics, performance and experience, strengths, capabilities, and professional promise from someone who has worked closely with the candidate. It is assumed that a confidential letter of recommendation will provide a candid viewpoint of an applicant's abilities and professional promise.
Letters of recommendation are often used by an organization's hiring officials to gather additional information about a candidate.