The advice of Nicodemus is given when he says: Does our law judge a man without first hearing from him and knowing what he has done? For according to the civil laws, a judgment was only to be given after a complete investigation. This is why we read: "It is not the custom of the Romans to condemn any man before he has his accusers face him, and can defend himself from the charges" (Acts 25:16). "I diligently investigated the stranger's cause" (Jb 29:16). And so the law of Moses says: "Do not condemn one who is innocent and just, because I hate the wicked" (Ex 23:7).
Nicodemus said what he did... because he believed in Christ and wanted to convert them to Christ; yet because he was afraid, he did not act very candidly. He thought that if they would only listen to Christ, the words of Christ would be so effective that perhaps they would be changed like those whom they sent to Jesus, and who, when they heard Christ, were turned aside from the very act for which they had been sent.
Source: Commentary on John