This question already has an answer here:
C-3PO has, in the words of Wookieepedia and this related question, a "fussy and worry-prone personality". He reacts poorly to dangerous situations, usually exclaiming some variation of "we're all going to die!" For example, the very first line spoken in all of Star Wars:
Did you hear that? They've shut down the main reactor. We'll be destroyed for sure.
In the top answer to the linked question, Null claims that C-3PO's personality is (mostly) that of a standard protocol droid, and it is natural for one to become anxious in dangerous situations.
A protocol droid often serves diplomatic functions. Negotiations and other diplomatic relations are potentially tense and stressful, and I think that you would want the people and droids involved to be able to stay calm.
While some of the situations in which we see Threepio—like actual battles—are probably outside normal operating parameters, he should still be able to deal with some level of stress. However, he even seems uncomfortable when working for Jabba the Hutt, even though that is exactly the sort of work protocol droids are supposed to do. Even in the more extreme situations, I can't think of any advantage to a diplomat or interpreter showing such visible fear and anxiety.
What reason is there for a protocol droid, like C-3PO, to be so anxious in stressful situations?