Firstly, increasing your HP stat protects you against both Physical and Special moves, because the same attack will take a smaller percentage of your HP. If you are not targeting a specific defense then increasing HP works the best.
Secondly, if your HP is lower than the defenses then it's mathematically better to invest in HP. Even if you're making a Physical tank and don't care about Special Defense, you should always increase whichever stat is the lowest.
Warning, nerdy maths coming up! Say for example your HP is 50 and Defense is 100, and a particular attack does 20 HP damage. That's 40% of your HP. However,
- If you added 50 to your Defense (so you have 50 HP, 150 Def), that's 1.5 more so you'd take 20/1.5 = 13.3 HP damage instead, which is 26.6% of your max HP.
- If you added 50 to HP (so you have 100 HP, 100 Def), that attack would still do 20 HP damage, but now with 100 HP that's only 20% of your max HP.
The opposite also works - if your Defense was lower than your HP you should increase Defense first.