Programmed primarily for etiquette and protocol, C-3PO has fairly high-end AI for a droid. By nature it seeks to minimize conflict, but it is smart enough to bluff its way out of tough situations at need. The droid is fluent in over six million forms of communication, including the binary language of astromech droids like R2-D2, Huttese, Wookiee, and something closely related to Ewok. It also knows many expressions of dismay, regret, and resignation.
C-3PO's humanoid body appears to be a cost-saving measure, as the droid has poor mobility compared to a typical humanoid or a battle droid.
C-3PO was built by Anakin Skywalker while he was still a slave on Tattooine, presumably from scavenged parts. At the end of the Clone Wars, it and ended up on Alderaan with Bail Organa, who had its memory erased. At the Battle of Scarif, it was serving aboard the Tantive IV under the command of Captain Antilles, but it eventually ended up as a long-time aid to Leia Organa.