First of all : Ninja Ninja is the imaginary friend of Afro.
Ninja Ninja (ニンジャニンジャ, Ninja Ninja) is likely to be a figment of Afro's imagination to cope with severe psychiatric trauma from unbearable sights and actions of death. Being that Afro is an emotionless murderer, his mind may well have created Ninja Ninja to hold his other emotions excluding Anger and hatred ; He often hangs with Afro as his self-appointed "Road Dog". Another possible understanding of Ninja-Ninja that would also be relevant to his regular Buddhist inspired spiritual practices is that Ninja Ninja represents Afro's "Mind", which tries to affect Afro through voicing doubts and fears. Contrasting Ninja Ninja against Afro's actions in this context gives Afro a different set of characteristics. As to say, he has fears, doubts and anxieties yet continues onward in spite of them.
A canonical reference which you yourself can verify is in Episode 5, precisely at 14m 05s, Justice quotted :
I almost chuckled when you killed that imaginary friend of yours!
Referring to the act where Afro killed Ninja Ninja but no blood splattered.
Now to add to the wiki, notice the contradictions in the two characters:
- Afro : Calm, composed, risk-taker, lives life on the edge
- Ninja Ninja : Afraid of all combats, high levels of anxiety, unconfident, slacky, always after them booties
Noticing these two character differences, it's safe to say that Ninja Ninja is the alter ego of the Afro's real self. He's a part of Afro that he himself refuses to acknowledge as a part of himself and treats it as somebody else. Why? Because of the Bushido or the Samurai Code. He can't allow himself (a samurai) to be unconfident, slacky, pervy or have a loose attitude. Therefore, he is tempted and warned and mocked by Ninja Ninja time and again, here and there.
Another reason I thought of, and which is mentioned in the wiki, is that all the burden of killing and slaughtering mercilessly could drive a person insane! He has to keep his mind off any such distractions. That's another reason of existence of Ninja Ninja.
Now to answer your question as to why he could interact with real world objects, he interacted with the same objects that Afro touched. Here are some instances :
In Resurrection he commented how awful the steak was! At the same time Afro was having the steak, but he (being a samurai after all) shouldn't be complaining about such things, but his alter ego did it for him to keep Afro calm!
He killed or discarded his alter ego in Resurrection by dodging a poisoned needle in such a way it hit Ninja Ninja, and also in the first season he killed it when he was about to face formidable enemies to prevent any second thoughts or distractions! And I don't remember if he was ever noticed by any other character in the anime. (Tell me on which episode at what time if I'm mistaken.)
Hope this seems reasonable!