I'm thinking with the samurai its a bit of a balancing act. They kind of keep the ninja on a leash and prevent them from doing anything too stupid. Which in turn the Ninja do the same thing for the samurai. the shogun or emperor keeps these two factions around despite the issue's they cause at times to keep each other from getting too powerful.