He didn't want anybody to see him consulting with Jesus, who was considered by many of Nicodemus' peers as nothing more than an itinerant carpenter who claimed to be a prophet. Nicodemus came to Jesus with what he thought was an intellectual need. Jesus perceived more. He knew that Nicodemus needed a spiritual rebirth. You must be born again.
Every person needs to be cleansed from sin.
Every person needs to be released from guilt's burden, filled with the Holy Spirit. They need to be made whole. Salvation isn't gained by doing good. Salvation doesn't come by thinking good thoughts and having good attitudes. Salvation doesn't come by joining a good church or by being baptized or by going to Sunday School.