Only female mosquitoes bite because they need blood, not for food, but to produce eggs. In fact, a mosquito, male or female, can live quite well without biting, just licking sugary substances such as the nectar of flowers. But a female will not lay eggs (or, in some species, only a few) if it does not manage to find a vertebrate whose blood it can suck.
The reason is that a nectar diet, despite being very energetic, does not provide enough proteins (amino acids) or other substances necessary for the generation of eggs, the oogenesis. And this has been proven experimentally: if a good combination of amino acids is injected into a female mosquito, it will produce eggs without having to ingest blood.