This is hardly surprising when you consider that Apple's business is selling a phone, where they generally have to throw in a cable so people can charge it, and Anker's business is selling a cable that you decide to buy even though you already had the one Apple gave you for "free".
Apple could make a better cable, but it's not worth it to do so.
That would make sense _except_ apple sells their cables on their website. They have already chosen to make selling cables part of their business.
What's more likely is that the quality doesn't matter. Lots of people only care about the official apple brand, so apple can get away with selling an interior product for more money.
Sure, they'll sell replacement cables, but they make a lot more "free" cables that sell with their phones and tablets. The cost/quality of the cables they package in phones matters to them a lot. They don't care a ton if additional cables sell well or not. And you're absolutely correct that many people will buy Apple official cables just because they're Apple official.
But here's the thing: Apple can't go selling premium cables and including cheapy ones in their phone boxes. The Apple brand has to be viewed as premium all the time, so they put a mediocre cable both in the box and sold on their website.
It sounds nice at first glance, but I don't think this argument holds up to scrutiny, because it could just as well equally apply to "companies other than Anker" manufacturing cables of this type, and the quality of a great many of those cables is almost notoriously terrible.
I'm certainly not saying Apple produces the worst cable. But that Apple only needs to produce a cable that isn't a detriment to the overall product: It usually works and accomplishes it's task. You aren't buying the iPhone based on the quality of the thrown-in charger cable.
Whereas Anker has distinguished itself as a company that makes quality cables... by selling quality cables.
Apple could make a better cable, but it's not worth it to do so.