For Health and both Defenses, you will always want perfect IVs. Every last hitpoint counts, and that one extra point in a defense can mean the difference between being KO'd, or surviving the hit. And these 3 stats all compound on each other, as well. Having that extra bit of HP will go even farther if it's protected behind that extra point of Defense or Special Defense.
Speed is usually best when maxed. There are a lot of scenarios where the first hit will set the tone for the rest of the match, and if you deliver a crippling blow before your opponent can even move, it can make a huge difference in the outcome of a match. Causing the opponent to flinch, or lowering their offense stat can stop a sweep in it's tracks. However, if you are using Trick Room, or certain Counter/Mirror Coat sets, it may not be so helpful. In fact, in the case of Trick Room, you would want a zero instead. This makes you slower under normal conditions, but faster during Trick Room.
For Attack and Special Attack, it depends on the Pokemon, and how you intend to use it.. If your Pokemon is Physical leaning in it's natural stats and moveset, then you would naturally want a perfect IV for Attack. There are also Pokemon that can be run using mixed stats, in which case you would want both Attack and Special Attack to be perfect to ensure you maximize your potential damage.
In the case of a pure Special Attacker, though, you generally want to get a zero in Attack if you can. The reasons for this are Foul Play and confusion damage. In both cases, the victim essentially makes an attack on itself, using it's own Attack on it's Defense and literally punching itself in the face. Because pure Special Attackers have no use for their Attack stat, you want to get it as low as possible to minimize the risk from these 2 sources of damage. This usually results in the want for a zero IV in Attack, and a Nature that is detrimental to Attack. There is also some carry-over to tanks, walls, and stalls in this regard. If the particular Pokemon uses Special moves instead of Physical ones, it only hurts you to have a high Attack stat.
Finally, all of this can be affected if you intend to use the move Hidden Power. This attack is unique in that the type it is when used depends on the the combination of odds and evens in the user's IVs. Getting a specific type from Hidden Power requires a certain combination of IVs. In this case, you may need to have a 30 in some or all of the Pokemon's stats, instead of a 31, to get the type you want/need for your moveset.