The ship's counselor on Starfleet vessels is responsible for the mental well-being of the crew, and is usually held by a senior Starfleet officer with training in psychology. As with the Chief medical officer, the ship's counselor has the power to relieve other officers and crewmembers of duty if he or she feels that their patient is sufferring from a condition that may hinder their ability to perform their duties effectively.
At the Captain's discretion, the ship's counsellor may be allowed to wear something other than their normal Starfleet uniform while on duty. This was the case with Deanna Troi, the ship's counsellor on the USS Enterprise (NCC-1701-D). (Deanna elected to wear a uniform permanently after being told to do so by Captain Edward Jellico.)
The USS Voyager was not originally assigned a counselor as its mission was intended only to last a few months. Later, Neelix appointed himself morale officer, a term of his own invention, to take on the responsibilities of a counselor.
According to a early draft of TNG: "Relics", Counselor Troi explained that the responsibility of a ship's counselor was to take care of the emotional well-being of a ship's crew and guests. Starfleet began assigning counselors to starships in the 2330s, after they realized that the pressures of extended space travel could result in psychological problems that would require professional care.