I am not sure about UPSs, but a diesel generator is built to generate a voltage between its two (four) output terminals. Whether these terminals voltage with respect to earth is high or low is not defined, and can't be. The generator per se is not connected to earth, so its neutral terminal might be some volts above (or below) earth as well as some (tens of) tens of volts above it. This might lead to tons of problems especially when you connect a correctly earthed apparatus to a generator powered one: their grounds are not at the same voltage so a spark might occur on connection, much like static on windy days. This should not be harmful for people but unfortunately electronics is quite more delicate and can suffer static discharges a lot.
Tying neutral to earth prevents this problem, and eliminates the risk for operators too.
Please note that this might not occur always since the generator chassis can be connected to the neutral, and the generator is usually placed on ground so a neutral-earth connection usually already exists. That's a poor connection, but sometimes is enough to prevent problems.
I am guessing that some UPSs may have the output fully insulated from the AC line input, if that's the case tying the neutral to ground is a good idea. If the output is not insulated I'd say that tying the neutral to ground is a bad idea since you are basically connecting the AC neutral line to ground, and that's something that happens in distribution cabins but should not happen in the end user wiring.