Johnny has nicely answered that it was to show his mental state but I feel it also helps to show his physical state, as he was physically not looking well and we can see some scars also on his body which look fresh, we saw scars on Cole later too. This indicates that they might also be given by ghosts to Vincent.
Behind the scene, it was the idea of the actor himself (From USA Today:
During a film workshop with Willis and Olivia Williams (Malcolm's wife, Anna), Wahlberg proposed playing Gray nude rather than the goth clothing detailed in the script.
"If Vincent is coming to stop his suffering and end his own life, then why is he wearing anything? To me, he strips down and is in the bathroom fully naked, clothes on the floor," says Wahlberg. "Bruce thought that was awesome and pitched the idea to M. Night, who was like, 'That's insane. I love it.' "
Wahlberg now had to fully look the part. "I had to become emaciated and change my physical appearance."
"I was so hungry. I was depressed," he says. "I cut off my life to get
ready for the role."
Five weeks later, he showed up to "The Sixth Sense" set having dropped
43 pounds to a scary 139. "I passed Night and he didn’t recognize me.
He just walked right past," says Wahlberg.
Sent to wardrobe, the actor found out that the film would be rated
PG-13, so that would require clothes after all.
"I was like 'Oh (expletive), I just lost 40 (expletive) pounds. And
now I have to just wear clothes.' I was so conflicted," says Wahlberg.
He struck a quick compromise: wearing Vincent's "tidy whiti"
underwear.
"I asked to make (the underwear) look like I hadn’t changed them in,
like, two years," he says. "They soiled them up. That became the
wardrobe."