I believe there are two reasonable ways to understand it.
The traditional understanding is that Jesus was trying to get the man to realize that his experience of Jesus actually implied that Jesus was God.
Mainline (including a lot of recent Catholic) theology would say that Jesus and Paul consistently distinguished between Jesus and God, but that Christians looking back at Jesus in light of the resurrection realized that God was directly present in him, and in many ways he acted as God, so that he should be viewed as God's way of being present in human life, but still a human being.
Here’s a good presentation of the latter view, from the conservative end of modern theology:
Jesus and the Identity of God - NTWrightPage
Here's the Anchor Bible's comment:
"(a) The question is intended to bring the man to perceive that Jesus was divine: “… that he may believe in the Son of God, not as a good master, but as the Good God” (Ambrose, De fide 2.1 and many patristic writers; cf. M.-J. Lagrange, L’Evangile selon Saint Marc [4th ed.; Paris: Gabalda, 1929] 264–265).
(b) Jesus rejects the epithet “good” from the questioner’s point of view and seeks to correct the magistrate’s flattery (so some patristic writers; see F. Spitta, “Jesus Weigerung,” 19);
(c) Jesus implicitly acknowledges his sinfulness. So G. Volkmar, Die Evangelien (Leipzig: Fues [R. Riesland], 1870) 489.
(d) The adj. agathos should be understood in the sense of “gracious, kind” (W. Wagner),
(e) Jesus is saying nothing about his own person, but directing the man’s attention to God and his will as the only prescription for pleasing him (B. B. Warfield, Christology and Criticism [New York: Oxford University, 1929] 139).
Most of these are subterfuges and one recognizes today that only the last is on the way to being the right interpretation.
...
Hence, if the magistrate recognizes any goodness in Jesus, he is being told by him to attribute it to its rightful source: “His [Jesus’] goodness is the goodness of God working in Him” (A. Plummer, The Gospel, 422)."
Fitzmyer, J. A., S. J. (2008). The Gospel according to Luke X–XXIV: introduction, translation, and notes (Vol. 28A, p. 1199). New Haven; London: Yale University Press. [extra newlines added for readability]
While I agree with Fitzmyer, I think it has implications for Christology that he is unwilling to pursue. Possibly as a Biblical commentator, that's not his job.