Praise be to Allah.
Is gelatin halal?
Some types of gelatin are of vegetable origin , and there is nothing wrong with using this or eating foods that contain it.
Some types of gelatin are of animal origin , and this is subject to further discussion. Whatever the case, there is nothing wrong with eating foods that contain it because even if it comes from animals that have not been slaughtered properly or other haram sources, it has been transformed into another substance that has different characteristics.
Is carmine halal?
We have not been able to find out whether what you say is true about carmine and its being derived from female ants. If we assume that it is indeed the case, if the sweet is not harmful then there is nothing wrong with eating it, because of what was mentioned above about the haram substance being transformed into a different substance.
Is it haram to eat lice?
With regard to lice, there is a difference of opinion as to whether they are impure. Some of the jurists say that they are impure because they contain blood and their food is blood. Some of them say that they are pure because they are likened to flies. But there is consensus that it is haram to eat them .
Al-Duraymi (may Allah have mercy on him) said: “It is haram to eat lice according to consensus.” (Hayat al-Haywan al-Kubra, 2/118)
It is haram to eat lice just as it is haram to eat maytah (meat that was not slaughtered properly) or drink alcohol. But if they have been turned into another substance by means of some treatment, then there is nothing wrong with eating that substance, as explained above.
It should be noted that the basic principle with regard to these foods and drinks is that they are permissible, because it cannot be said that any of them are haram on the basis of speculation.
Similarly, it cannot be said that most of the sweets contain gelatin , because this is contrary to reality. If a person wants to avoid things containing gelatin or carmine, he will find plenty of other alternatives in other types of sweets.
And Allah knows best.