Flanking gives a withdrawal chance if the unit would otherwise lose.
This has 2 uses:
1. Attacking a very strong unit such as a cg III archer or longbow, in hopes that your unit survives but does it damage.
2. Attacking and (hopefully surviving) a stack of enemy soldiers in your territory. If your mounted unit lives, either through victory or withdrawal, you damage the enemy siege. It is actually possible to KILL enemy siege without killing the other units defending it this way. In a war between armies with fairly large #'s on either side, this plus walls can easily decide who loses and who wins and keeps 75% of their stack or more. My highest scoring game ever (230k points just last night) involved just such a situation, against PRATS. I was Germany, and my HA's saved me big time.
Also note that since flanking II gives first strike immunity, you can use that on cavalry to give them ridiculously high retreat odds and nearly guarantee damage to a defender - even those obnoxious units like machine guns etc.
I've taken entire maps with combinations of flanking II, combat shock, and straight combat mounted units, supported by spies.
It functions so that you want to use other promotions when you are likely to win, but you have the best % of survival and efficiency via flanking when the defender has higher strength than your attacking unit.
Note that if you can somehow get them pre-1AD in force, flanking + combat HA's absolutely trounce the AI (I can vouch for it up to emperor). My 230k game actually led me to HA rushing sitting bull (!) since he was smaller than other civs and a heathen scapegoat target. Ignoring the drill/first strike was nice, the CG was a pain - but HA's IMO were just as effective there as ANY OTHER UNIT would have been, and as I mentioned above they saved me later on as I eviscerated 2 equal-size stacks with them...gotta love promotion advantages
.