We currently have no explanation for this as the only move any Magikarp may possess is 'Splash' which deals no damage and therefore is completely ineffective in battle. Thus, it can be concluded that a Magikarp may never be able to defeat any other Pokemon, which means it may never gain XP, hence, it should [i]logically[/i] never be capable of evolution. Yet, we know this is not the case.
[spoiler]One of lifes greatest mysteries...[/spoiler]