In fact, the samurai moral code required warriors to live lives of service and obedience. The earliest samurai, who lived in around the 10th century, worked for the emperor. Some guarded his palace, in the city of Kyoto, while others defended remote villages from bandits and pirates. People believed the emperor was descended from the ancient gods of Japan, but that didn't mean his divine blood gave him special powers.