He had an incredible character arc that had so much potential but was clearly cut down to keep the focus on the trio of Jack, Will, and Lizzie. It’s very clear in Dead Man’s Chest that there was a lot he went through before winding up drunk and broken in Tortuga, and those events molded his viewpoints in At World’s End.
[A short summary of those trials: After letting Lizzie go to be with Will, James takes off in the Dauntless to, of course, hunt down Jack. This resulted in a lot of professional problems with his SOs in England, likely a good portion of his crew abandoning him or being reassigned, and then that hurricane Gibbs refers to. So when James says my story’s the same as yours, just one chapter behind, that’s not an exaggeration.]
DMC is where we see James at rock bottom, as compared to his rising star in The Curse of the Black Pearl (CotBP). He’s not a sharp military man; he’s just another sailor and (a very unwilling) pirate, just as grimy as the rest. But he’s a fascinating juxtaposition to Jack (motivated by his own interests and desires) and Will (motivated to protect his family) even if that whole three-way duel, while visually fascinating, just seemed so stupid to me. [Yes we all know you guys want to use the chest as leverage to get something, let’s put goals in order and use teamwork. Not even going to touch the fact the three of them are, in one way or another, Lizzie’s suitors and she knows it.]
Then comes At World’s End (AWE). James has gotten what he wanted - his reputation restored, all mistakes forgiven - but at the cost of being made into Beckett’s pet. It’s a situation he despises, but after hearing of Lizzie’s “death” and finding out the secret of the Heart with ex-Governor Swann [this is in a deleted scene], James has to figure out a plan, something to stop Beckett. For all he knows, the woman he loves and the two men he’s had to entrust with her safety are all dead, and he the last one with the agency to act - even if it means giving up his career all over again. Of course, the Dutchman capturing Sao Feng’s ship reveals that, no, Lizzie isn’t dead - and James sees he now has an ally. He doesn’t even thinks about the fact he’s in EITC colors; all he cares about now is protecting Elizabeth and preventing Beckett from hurting her.
Hence springing her and her crew from the Dutchman’s brig and directing them to safety. Hence, when Lizzie tells him to go with her to the Brethren Court, he is ready to get on those lines and get the hell out of there.
But being the caring man that he is, when Bootstrap finds them, James willingly stays behind. He has to trust Elizabeth to do what she does best.
The other ships will still be looking to us, to the Black Pearl, to lead, and what will they see? Frightened bilge rats aboard a derelict ship? No, no they will see free men and freedom! And what the enemy will see, they will see the flash of our cannons, and they will hear the ringing of our swords, and they will know what we can do! By the sweat of our brow and the strength of our backs and the courage in our hearts! Gentlemen, hoist the colours!