Why is it that v'halachta b'derachav, imitating G-d, applies only to his acts of mercy? We are told (Sota 14) that G-d visits the sick, buries the dead, acts charitably, and we are expected to do the same. But no source suggests that just as G-d smites the wicked we should do the same -- a thought that undoubtedly occurred to many who were listening to the Madoff sentencing yesterday. Why not?
The Maharal (Nesiv Gemilus Chassadim) explains that when a person faces a situation that cries out for justice, s/he is forced by circumstance to respond. The same may be said for many types of charity. Giving a quarter to the homeless guy begging for change just to get him to stop annoying you or putting a coin in a pushka to avoid feeling guilty is also just a response to a situation, an means to avoid a negative feeling rather than a desire for constructive good. Situation and circumstance, not a person's inner character, is what motivates these behaviors.
G-d "has" everything; he does not suffer needs and is not compelled by circumstance -- and still he gives. We too can only claim to imitate G-d when we act not because of personal needs or circumstance, but simply because it is the right thing to do. In a word, imitating G-d demands altruism -- a selflessness that motivates one to do good for its own sake alone.