Disclaimer: Not an electrician; do your homework before messing with this stuff or better yet, hire a professional; seriously don’t listen to some random guy on the internet.
In power generation the “earth” is the literal return path that the neutral is bonded to. So when you tie a building into the grid, each structure makes the connection back to the ground to complete this path. But with a portable generator the earth is not used as a return because the generator is the source of power and it has no connection to a power generation plant. Instead the neutral and ground lines are bonded together and are grounded to the frame of the genny. This makes the whole generator and anything attached to it a floating system which is totally fine and safe. But in a highly energized atmosphere a lightning strike that may hit the genny or any equipment attached to it has only this self contained system to dissipate the energy through. Eventually it will dissipate into the ground (just because of the huge potential difference between the earth and the atmosphere), but not without going through every single wire, chassis, and person in contact with it first. So it’s not like a hit will just take the genny out; it takes everything out, and that’s a lot of equipment and people all sharing a physical connection in one isolated network. And just like @documentarysoundguy said, any metallic, elevated, positively charged surface (looking at you aerial antennas) can attract a potential strike, especially in an open air situation.
The whole idea is one of safety and an abundance of caution. It simply isn’t worth the risk. I work primarily as a live sound engineer and any time there is an energetic atmosphere and strikes within a mile of an outdoor event using portable power and an elevated stage, things get shutdown until it’s all clear. Rain is fine; lighting is no bueno.
Even indoors isn’t totally immune to an energetic atmosphere. I once had a large, visible, and loud static discharge off of a sub stack into the air. The speakers were sitting on rubber shock pads to keep them from moving around and the constant moving of the speaker cones, that were coupled to the air, generated a sufficient enough potential difference that it arced. Outside was a very beautiful and active lighting storm with no rain. It was the most bizarre thing.
Anyway, all that is to say it’s just a good and safe practice and there isn’t anything particular about the generator other than the entire network being electrically isolated which in and of itself has a higher probability of danger in an electrical storm.
I should also add the caveat that I’m not an expert in this at all and this is just my best understanding of the subject.