When Jesus was preaching the fulfillment of the Law in the Sermon on the Mount, He explained that we are to love our enemies that we may be children of our heavenly Father, Who "makes His sun rise on the bad and the good, and causes rain to fall on the just and the unjust." If we do so, we will be perfect, just as our heavenly Father is perfect.
Okay, but what does making His sun rise on the bad and the good have to do with the Father being perfect?
For one thing, I suppose, it is a mark of His justice. In Psalm 51, David sings to God: "You are just in Your sentence, blameless when You condemn." The criticisms against God for being somehow unfair to His creatures is unfounded.
Moreover, without the sun and the rain man cannot live. By blessing the unjust with these gifts, God gives them time to repent -- time that will count against them in judgment should they fail to repent.
So perhaps loving your enemies that you may be a child of your heavenly Father is not so different from loving them that burning coals may be heaped upon their heads.