A logical answer could be all the gnomes would just say "red" and that way about half of them would escape on average, assuming the hats were distributed randomly.
This is a good start and should naturally lead to having every other gnome say the color of the hat in front of them. The first gnome would say the color of the hat in front of him, then the next gnome would just say that color that was just said. So we can guarantee that half escape - the even numbered gnomes (since the gnome behind them told them the answer). And potentially if the hats were distributed randomly some of the gnomes would get lucky and the hat in front of them would be the same color as their own. So this strategy should save more than half, and on average 75% of them would live.
Some answers might include, "they could agree that if they said their hat color in a soft voice, it means the hat in front of them is the same color, and if they say it in a loud voice, it means the hat in front is a different color". this is definitely good and on the correct track. another option is they could say "reeeeeeeeeeed" for x number of seconds, where x represented the distribution of hats where a hat was a bit in a binary number, (red = 1, blue = 0). another interesting answer. There are many others like these that "bend" the rules a bit and come to a solution.
But the real solution acknowledges that the gnomes can only say "red" or "blue" and cannot alter their voice in such a convincing way as to signal any information other than the word they said. The wizard gets to hear their plan before he puts the hats on, and so will try to thwart the plan however he can.
So if they decide to all say "red", he'll put blue hats on all of them. If they decide to all say the color of the hat in front of them, he'll alternate the hats on every head, guaranteeing half will die. But even with the wizard hearing their plan, there is still a way to save almost everyone.
We know that the first person is never going to have any information about the color of their hat, so they cannot be guaranteed to escape. But, i'll give you a hint to the solution: I can save every other person for sure.
The gnomes agree that if the number of red hats that the back gnome can see is even, that gnome will say "red". If they add up to an odd number, they will say "blue". This way number 99 can look ahead and count the red hats. If they add up to an even number and number 100 said "red", then 99 must be wearing a blue hat. If they add up to an even number and number 100 said "blue", signalling an odd number of red hats, number 99 must also be wearing a red hat. Number 98 knows that 99 said the correct hat, and so uses that information along with the 97 hats in front to figure out what color hat is on 98's head.
Sample:
100 99 98 97 96 95 94 ... facing -> R B B R B R B ... -> 45 R and 48 B
this shows #100 wearing a red hat, 99 a blue, 98 a blue, 97 a red, 96 a blue, 95 a red, 94 a blue and 45 red hats - 48 blue hats on the gnomes in front of them.
100 counts up the red hats: 47 total. so 100 says "blue". The wizard enslaves 100. 99 counts up the red hats in front: 47. 100 said blue, so 100 saw an odd number. 99 sees an odd number, so 99 says "blue" and lives. 98 had counted 47 red hats, and 99 didn't say "red" so thats still the total. 98 says "blue". 97 counts up and finds 46 red hats. 99 and 98 didn't say "red", so his count is missing a red hat (its on his head, he realizes). He says "red". 96 heard the "red" and now knows that there are an even number of "red" hats in front of 95. 96 sees 46, so he knows he has a "blue" hat. etc...
Even if the wizard knows the plan, he can't thwart it. He hears the plan, but he still has to put the hats on their heads. The plan doesn't rely on any ordering of the hats, so the worst the wizard can do is to make sure #100 gets enslaved and thats the worst damage he can do.