In Edo period theater in Japan, playwrights needed a trick to show how sneaky ninjas were on stage, as well as a way to make them into “invisible” assassins. The stage hands already dressed in all black, so the audience had long been used to ignoring them since they weren’t “part of the play.” So, actors playing ninjas started dressing up in all black, too. Then the whole audience would jump when one of them would leap out of nowhere and kill someone. And thus the myth that ninjas wear all black was born. In actuality, if they needed to walk around at night without being seen, they’d wear dark blue, which doesn’t have a silhouette. But that wouldn’t be as dramatic in a movie preview.
The article from Cracked points this out too:
The ninja outfit is ridiculous, if you think about it. If you’re an assassin and your job is to blend in, you don’t do that by dressing in a black bodysuit that screams “ninja” from a mile away. So, they dressed like normal people—workers, monks, merchants, basically anything that looked as un-ninja as humanly possible was the perfect disguise. This way, they could sneak around unnoticed, day or night.