—————
Not sure where to put this. (I am guessing that it belongs in Discussion, but I do not know “where” that is.) [Feel free to move it there, but leave me a link.]
Pardon me if I take the liberty… . [You did say that the insects were “planet-devouring”, but I am taking it that your thinking is not settled yet.]
It seems to me that you have a fundamental choice to make — do the insects do anything to the Earth directly [or indirectly — see below * ] or not (and if so what and why). Maybe it is merely that they land on it in large numbers (noting the day/night cycle). [Or possibly the survivors do not know yet… or possibly the insects’ behaviour is not yet properly understood.]
If they do not, then the Earthians do not need a shield for the Earth; they just have to survive the event… which, in this case, would be inconsequential unless the insects significantly interfere with or destroy the Sun —— they might • blot out the Sun for a time and then move on (with or without some damage of it) • blot out the Sun, and later destroy it, • destroy it immediately (which would be rather odd), or • not be a problem until they destroy the Sun.)
Further, in that case, shielding the Sun before the event might be no less difficult than repairing it afterwards… although there is the issue of them possibly coming back.
Offhand, it looks to me as though you do need them to “devour planets”. This works in the immediate sense; we build a Dyson sphere (or some other fancy solution such as my original answer) or we die; their arrival must be prevented. (It is unlikely that any sort of military shielding of the Earth would work.)
Note that, given this, it does not really matter whether or not they destroy the Sun; presumably, they leave when the planets are consumed.
I am thinking, though, that, in terms of plausible life cycle, a swarm that comes and eats vast amounts of dirt (and possibly gas), reproduces (possibly destroys the star) and moves on is a bit B-grade movie. Maybe it is just how I am putting it, but I am thinking perhaps something more subtle… .
The core idea is that these things are phototropic — they go towards the light. If they do not consume the planets, then arguably the only reason they might leave is if they do indeed destroy the Sun… which is not especially “subtle”. Conversely, I am thinking that this — i.e. not eating the Earth — might work better for building a history around.
So… they do interfere with the Earth in some way, but not massive military-like destruction.
{Asterisk}[footnote/reference]
I had a couple of ideas around interfering with orbital mechanics, but I do not think it would work [insufficient mass], so I have deleted it. I thought the rest was okay, so I am still posting this.
Independently of that… stopping the Sun from shining would involve some dramatic change, but, even given that, significantly changing its mass would be an even bigger change ( unless the insects increase vastly in number when procreating, taking the differential mass from the Sun ).
[Passing thought: would a Dyson sphere interfere with orbital stability?]
If the insects do do something more subtle that would ultimately ruin the Earth, then the Earthians still do have to prevent them from coming. [I am assuming that their technology level is so high that restarting the Sun is on the cards.] This also has the attraction of involving a slow death (if they do end up coming).
…Except that, given the high level of technology, it might be feasible to have the insects come, and do their damage, and leave… and then set about repairing everything. [Again, this might work better for a long history.]
Conversely to all that… if the level of available technology is so high, arguably just about anything is not going to be a problem… and conversely again: just because we know how to (e.g.) move the Earth does not mean that it is trivial to do it, and similarly for any engineering that requires vast amounts of any resource.
Similarly for (eg) building a Dyson sphere; even if it is trivially easy in terms of knowledge, there is still the issue of physically getting the material and building the thing.
There is also the possibility of more subtle measures against their life cycle — possibly something discovered accidentally, such as that they are attracted to (military) electromagnetic shields.