This man was seeking to be justified in the sight of God through his actions. He knew he had not loved everyone as he loved himself, so he is tried to interpret the scripture (Leviticus 19:18) in a way that would conform to his actions. He wanted to define "neighbor" as just his close friends whom he had treated well.
Self-justification always produces excuses, while repentance and faith toward God produces obedience.
The basis of our salvation is grace, that is, God's undeserved, unmerited favor toward us as shown in providing redemption through Christ Jesus.
The means of God saving us is through faith. Through faith we accept God's free gift of salvation, which was provided by grace. So we are saved "by grace ... through faith. We are not saved by grace alone. We are saved by grace through faith. Faith grants us admission to God's grace. Without faith, God's grace is wasted, and without grace, faith is powerless. Faith in God's grace has to be released to receive what God has provided through Christ.
Just as sodium and chloride are poisonous by themselves, so grace or faith used independently of each other are deadly. But when you mix sodium and chloride together in the proper way, you get salt, which you must have to live. Likewise, putting faith in what God has already provided by grace is the key to victorious Christian living.