What is the main purpose of a samaurai?

The samurai were a noble class of warriors in medieval and early modern Japan. Their purpose was to serve and protect the nobility, with heavy emphasis on honor and loyalty.