On average, the Navy publicly fires 12 (about 1.2%) of its Commanding Officers annually (accurate statistics are not available on XO firings). In Accordance With (IAW) Navy Regulations, the Navy gives broad authority and responsibility to its commanding officers - afloat and ashore - who number more than 1,000 (commands as listed in the Navy's Standard Distribution List (SNDL)). A single mistake can usually end a career. Some criticize this as a "zero defects mentality". But, let's be honest - these are usually huge mistakes. Grounding and collisions are costing the Navy 100s of millions of dollars. In these cases, the Navy has no alternative but to fire the responsible Commanding Officer (and usually several other responsible officers, Chief Petty Officers and Sailors).
Nor is the Navy shy about firing its Commanding Officers for personal misconduct, ranging from extramarital affairs, false travel claims, illegal or improper use of government property to alcohol abuse (typically resulting in a DUI/DWI which comes to the attention of Navy authorities). Several Navy Captains who were certain Flag selectees have seen "their Flag" flushed down the toilet over DUIs.
The Navy Inspector General's reports in 2005 and 2008 found that Commanding Officers were more likely to be fired for improper behavior than for poor job performance (groundings, collisions, failed inspections, creating a poor/hostile command climate, etc). One of the reasons for this is that in this age of information sharing, more improper behavior is being reported by command members than in years past. More than half of the Commanding Officers were fired because of misbehavior.
Navy IG reports note that a "CO's failure to follow established regulations, laws, moral or ethical principles, occasionally after being counseled, was the primary cause of most" of the actions. The report also found that most dismissals for misbehavior involved adultery (often with the wives of subordinates) or alcohol abuse.
For my part, more open discussion of the reasons for firing Commanding Officers would serve to better educate others on appropriate behavior demanded of Navy officers selected for command. Navy Regulations set the standard (Article 1131 below) - the Commanding Officer need only live up to it.
1131. Requirement of Exemplary Conduct.
All commanding officers and others in authority in the naval service are required to show in themselves a good example of virtue, honor, patriotism and subordination; to be vigilant in inspecting the conduct of all persons who are placed under their command; to guard against and suppress all dissolute and immoral practices, and to correct, according to the laws, and regulations of the Navy, all persons who are guilty of them; and to take all necessary and proper measures, under the laws, regulations and customs of the naval service, to promote and safeguard the morale, the physical well-being and the general welfare of the officers and enlisted persons under their command or charge.