I love that you have to defend the decision to build ironclads. Just shows you how useless they are in 99% of games.
To answer your question though, the caravels have 3:6 strength against a privateer, which are pretty poor odds. A human player would say "ok, i'm gonna lose at a ratio of 3:1, which is worth it", but the AI's value calculation doesn't extend that deep. I wonder if there is a hard-coded value somewhere in the program?
The will of a unit to attack yours is tied to five components:
1) Unit courage
2) RNG
3) Stacks
4) Unit scripts
5) Bad AI decisions
Unit courage is an XML value tied to every leader where there is the normal unit courage (that is if the AI has at least 50% of win, it attacks you). More courageous leaders (like history told us) like Nappy and Ragnar being at the end of the spectrum will attack at lower threshold accepting more the losses. That is why you're all used to Monty suiciding heaps of units to your Machine Guns than any other leaders (although if Ragnar and Nappy were as bad techers, they would be worse!). Barbs have twice the unit courage of regular civilizations.
RNG will change the AI unit odds to attack especially at the second turn of the confrontation. I mean they are next to each other but the RNG changes the "unit courage" next turn by making the unit more courageous plus adding some RNG flavour.
Stacks global power is an essential component to understand why those advanced AI units refuse to attack you even with good odds unit vs your best defender.
AI considers stacks as a whole for the power measurement. A reason why it happens that you medieval huge stack never got attacked even if the AI has better.
Unit scripts define the AI behaviour and the odd thresholds the unit will agree to attack. Unit scripting was defined to give roles to AI units. There are city raiders, attackers, city defenders, unit counter, etc. Each type has its particularity. My best experiences came from archers because those units receive the largest spectrum of unit scripts. From city defenders to city raider. A prime example is the city defender archer will recoil to high odds winning while the attacker archer is more prone to attack.
Ai bad decisions come from funny instances. I mean just like those stacked orders that ennerve people when starting a new turn and the units move before you can cancel the stacked orders. Sometimes, I have seen suicide archers that make no sense. Although I haven't found a appreciable explanation, I think those weird AI units are probably coming from "bugs" or better said particular missions that weren't updated. BTW, missions are not equal to scripts. Scripts define AI unit behaviours. Missions define an order. Like founding a city, going all the way to point A to B.
A prime example of a script vs a mission is the "Why don't you attack that city?" diplo action. Most thinks that action is broken but it isn't at all. It definitely works. The stack will be given a trajectory from the present location to the city target. The problem is the mission given will be dissipated by annoying enemy units that pass by the stacks and because of unit scripting, the stack will attack that unit (imagine a weak enemy scout) and then forget the previous given mission to attack that city. A reason to give each turn that order to your ally.
That's all for it and don't take it for granted. Myself I'm not sure about it. AI units along AI cities behaviours are the hardest to grok.