How to EV a Pokemon defensively
If Pokemon's HP < Defense/Sp Defense, max out HP first
Examples: Shuckle, Dusknoir, Bronzong
If Pokemon's HP > Defense/Sp Defense, max out Defense and/or Sp Defense first
Examples: Blissey, Snorlax, Wobbuffet
If Pokemon's HP is equal or nearly equal to Defense/Sp Defense, max out HP first
Example: Celebi, Jirachi, Nidoqueen
Example: Let's take 2 Spiritombs with the same IVs and the same level. Spiritomb 1 will have max HP EVs and the rest split in both defenses. Spiritomb 2 will have max EVs in both defenses and only 4 in HP.
Spiritomb 1 with 252 HP / 140 Def / 116 SpDef (neutral nature)
Spiritomb 2 with 4 HP / 252 Def / 252 SDef (neutral nature)
Here's how much damage they will take from the following attacks:
STAB Earthquake from Pokemon with 300 Attack:
Spritomb 1: 36.8% - 43.8%
Spritomb 2: 42.6% - 50.8%
STAB Flamethrower from Pokemon with 300 Special Attack:
Spritomb 1: 35.9% - 42.8%
Spritomb 2: 40.9% - 48.3%
As you can see, Spiritomb 1 takes less damage from both Special and Physical attacks than Spiritomb 2 even though Spiritomb 2 has more EVs in both defenses. This shows you how important HP is for a wall that has less HP than defenses.
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~