The black costume associated with Ninjas in popular culture comes from Edo period Japanese theater, and was supposed to be a symbolic representation of them as invisible assassins. Ninjas themselves are largely an invention of Edo theater. The word "ninja" is basically the Japanese equivilent of a contraction/abbreviation for "Shinobo no mono" (person of stealth). It was a job description, like "spy", not a distinct social class (like samurai) or a clan or underground society (like the Yakuza). The popular conception of ninja has about as much connection to reality as James Bond.

In reality, "ninjas" relied as much (if not more) on disguise, treachery, and subterfuge as on stealth and concealment. Why climb the walls to a castle when you can bribe, blackmail or intimidate someone into opening the door for you? Why wear a giveaway black outfit and hide in shadows when you can disguise yourself as the janitor or gardener and hide in plain sight? The unusual weapons of the "ninja" (and many other oriental martial arts) -- mostly re-purposed agricultural tools -- were a reaction to the fact that a peasant (or person disguised as a peasant) carrying a "real" weapon would likely be executed on the spot.

Of course life copies art as much as art copies life, so the theatrical ninja costume did eventually get adopted by real-life modern ninjutsu practitioners, but that is a relatively modern invention.