According to the laws of LU (a state where Confucius lived), in foreign states, if someone ransomed a slave who was a LU's citizen, LU government would pay him the reimbursement.
Zi Gong (Zi Gong is one of best students of Confucius, a well learned scholar and capable eristic.) ransomed a slave, but he refused to apply for the reimbursement. All who heard about this thought that he did a right thing. But Confucius did not agree.
He said to his student: "Zi Gong, you did it wrong. What a man of noble morality does is not only his own issue but may also affect others' act or even change the social custom. Thus, before you refused the reimbursement, you should have thought about what effects it might have on others. If you accepted the reimbursement, it would not impair your kind deed. But you refused, then common people would take you as the model. However, now most of people in LU are not rich. I am afraid that nobody is willing to ransom their compatriots in the future."
Zi Lu, another student of Confucius's, once saved a man from drowning. To express his gratitude, the man gave Zi Lu a buffalo, and Zi Lu accepted.
Hearing of this, Confucius was very happy and said "From now on, the number of those who are willing to rescue drowning people must be increasing."
There is no doubt that ransoming a slave and refusing reimbursement is a good deed. But for Confucius, the long effects that a good deed might have were much more important than the good deed itself. This may partly explain why Confucius was worshiped as the sage with the ability to foresee.