Mosquitoes don't sting you for their own entertainment, nor are they doing it in self-defence (as is usually the case when bees sting). Both male and female mosquitoes get nourishment from nectar, not from blood.
Mosquitoes require protein and iron to develop their eggs, two substances they can get both from blood. Only the female mosquito feeds on blood, and she only does so when she's developing eggs.