You just demonstrated a nice AI bug.
Ragnar had that archer in the city which you only had about a 1% chance of winning against, so what does he do? He moves it out of the city. Given the bonuses it was getting it must have had something like city defense 3, combat 1, the lush terrain promotion, and the flaming arrows thing - and possibly more. I think he moved it next to the city on top of the horses where the city defense promotions it had did nothing, and the best unit left in the city only had something like a 10% chance of not getting killed by one of your swordsmen instead of the 99% that the archer had.
Definitely an AI bug. The whole desire to keep and/or move units outside the city onto good defensive locations or to protect resources is definitely taking things too far. Protecting the horses from being pillaged is useless if you lose the city that is getting you the horses (which is exactly what happened).
By the way (you knew that was coming, didn't you), ranged bombard is very iffy in it's usefulness - I don't know what the accuracy number is but it is not a direct percent chance of hitting, at the very least there must be some modifiers that can reduce the chance considerably since a supposed 70% chance seems more like 35% or less (it seems to have about a 1 in 3 to 1 in 4 chance of doing damage, on average). It also apparently never directly damages the strongest defender. Just like regular collateral doesn't damage the unit that actually defended against the unit's attack, the ranged bombard does not seem to damage the until that would have defended if it has attacked normally, which is the same unit. With a healer in the city there is also pretty much no chance that collateral damage is going to build up unless you do a lot of it every turn: even without a healer a unit in a friendly city heals 20% per turn, to which the healer's 20% (or whatever) is added for a total of something likely to be 40% per turn or more. There could also be buildings in the city that increase the healing (like +10% from a healer's hut). So the whole concept of sitting around hoping to weaken the enemy by turn after turn of ranged bombarding the city a lot is not a good one, especially in light of the next thing...
Also, that taking damage from buildings in the enemy city is from buildings in the enemy city (what a surprise). The various tower like buildings (with names like frontier outpost, fortified outpost, guard tower, and so on) have some chance to do damage to units adjacent to the city every turn (this appears to be a better chance than the ranged bombard has of doing collateral damage). The pit traps, mechanical traps, and so on line of buildings also does this. It can get up well over the amount you can heal in enemy territory (normally 5%) without a healer, leading to a pretty rapid loss of health when you sit next to an enemy city that is a lot like trying to heal on damaging terrain (only worse because once you are damaged enough for their chances of winning when attacking get good enough they will tend to start attacking you).
And finally, your newly captured cities don't need health they need happy. Build happy producing buildings. Or if you completely wipe out the civ you took it from then the unhappiness from being largely foreign in culture goes away since the dead civ's culture disappears.