Allow me to explain.
This is the equation for damage calculation, quoted from Serebii
((((2 * Level / 5 + 2) * AttackStat * AttackPower / DefenseStat) / 50) + 2) * STAB * Weakness/Resistance * RandomNumber / 100
Simple enough equation, just a bunch of variables to plug in. If you see that "Random Number" variable, this is what causes the variation in damage. The random number is generated between 85 and 100. Take the following situation:
Lv. 500 Magikarp uses Explosion on Lv. 500 arceus. Let's call Magikarps attack 10,000, and arceus's defense 8,000 (Just for kicks and giggles). We input the statistics:
(((2*500/5 +2) *10,000 * 250 / 8,000) /50) +2) (No STAB, *1) * 1 (No weakness or resistance) * 94/100 (Random Number). Now we can calculate, with this random number that Magikarp does 1188.63 HP in damage. This could range all the way up to 1264.5 damage, or as low as 1074.825 damage.
And please, nerds, don't come in and tell me that magikarp can't learn explosion-- take it from me