In 1985, Coca-Cola research showed people actually preferred the flavor of Pepsi, so they made a taste-tested Pepsi clone. It was launched as New Coke, and despite people preferring New Coke in blind taste tests, they still wanted to buy and drink Coca-Cola Classic. New Coke was a massive flop.
So even if Pepsi managed to make a perfect Coca-Cola recipe clone, they're missing the main ingredient - their brand.
Also their distribution network. There's plenty of stores that stock Coca-Cola products exclusively. Having the exclusive contract to supply McDonalds must help them a lot, for example.
That said - in Australia, Pepsi Max is actually #1 [1]. Coca Cola has had some problems in Australia with stores & supermarkets refusing to stock their products. (Dominos Australia recently dropped all Coca-Cola products & switched to Pepsi.) [2]
[1] https://asahi.com.au/brands/soft-drinks
[2] http://www.news.com.au/lifestyle/food/drink/woolworths-deliv...