I didn't say it was optimal to run away. I said it was optimal, in the context of the adventure goals, to resolve the encounter without expending resources to fight the giants.
Not to pile on, but that's not what you did. You used a lot of resources, but ineffectively. You used 40% of your paladin's LoH, one of your wizard's portents to protect the paladin from an unnecessary AoO, and a 4th-level slot for...
magic missile. And I guess that was just the first round of this Medium encounter. Having expending all these resources, how much closer was your party to resolving the encounter due to the actions you took? The big giant can just walk up to either you or the paladin (or anyone else he wants) and smack you. You walked off and left the cleric engaged with the other giant. If you do get to the collapsed area, now you have difficult terrain and the giants don't.
Exercise for the reader: how can the PCs achieve this optimal play?
1. Kill the monsters quickly by expending as few resources as possible.
2. Battlefield control and mobility buffs for the party to enable escape.
You didn't pursue either strategy. You expended significant resources on actions that didn't bring you closer to resolving the encounter. I guess you were roleplaying, which is cool, but it's probably not the right approach (IMHO) in an experiment such as this.
What could you have done, given (1) and (2)? Well, the paladin and the wizard are coordinating. I would have had the paladin cast
shield of faith and attack the giant (i.e. "tanking"). The last thing you want to do is give the giant a free attack! Your wizard can cast a spell to buff the paladin (thereby helping him tank) or debuff/control the giant(s). Given that the big giant is in melee with you and could attack you instead of the paladin, maybe you don't want to buff the paladin (i.e. turn him into a giant ape) because the giant might attack you instead (probably he attacks the giant ape and not the puny human, but maybe not). So you opt for control. The frost giant's saves are Wis +3 and Cha +4, so worst case scenario, a control spell is automatic with your portent die (which you used anyway, on an unnecessary AoO). Chances are, you wouldn't even have to use it. How about
banishment? For that 4th-level slot you used for
magic missile, you could automatically send the big giant to a harmless demiplane for 10 rounds. For a 5th-level slot, you can probably send both giants there, but that probably isn't even necessary.
So then, at the end of your turn, your paladin has buffed his AC and maybe done a little damage. The big giant with magic axe is out of the fight. You haven't used any LoH, you've still used a 4th-level slot, and you probably haven't had to use a portent die. Is that better or worse than what you did?