Why did Jesus tell the rich young ruler he could be saved by obeying the commandments?

Thus, the man was breaking the two greatest commands; he did not love his neighbor as himself, and he did not love the Lord with all his heart. He loved himself (and his money) more. Far from keeping “all” the commandments, as he had claimed, the man was a sinner like everyone else. The Law proved it.

.. If the man had loved God and other people more than he did his property, he would have been willing to give up his wealth to the service of God and man. But that was not the case. He had made an idol of his wealth, and he loved it more than God. With surgical precision, Jesus exposes the greed in the man’s heart—greed the man did not even suspect he had.