First, he acknowledged Jesus as good but not as God. This is the main thing.
Every major religion of the world acknowledges that Jesus lived and will even admit that He definitely was a good man, but they won't recognize Him as God. If Jesus was only a good man, He couldn't save anybody. Jesus didn't just come to show us the way to God. He was the way, the only way unto the Father.
No man could come unto the Father, but by Him (John 14:6). Jesus had made this point publicly many times. This is the reason that Jesus responded to this young man's question the way He did. Jesus was saying, "God is the only one who is good. You must accept me as God or not at all."
Jesus was either who He claimed to be or He was the biggest fraud that ever lived. He has to be one or the other. He cannot be both.
The ruler asked what he could do to produce salvation. He trusted in himself and believed he could accomplish whatever good work Jesus might request. This is completely opposed to the plan of salvation that Jesus came to bring.
Jesus obtained salvation for us through His substitution and He offers it to us as a free gift. All we must do is believe and receive.
This rich young ruler wasn't looking for a Savior. He was trying to be his own savior. This is the reason Jesus referred him back to the commandments. He either needed to keep all of the law perfectly or he needed a Savior.
Jesus desired to turn this man from trusting in himself by showing him God's perfect standard, which no one could keep, so that then he would trust in a Savior.