Is riding shirtless safe?
Safe is a relative term in this instance. A shirt might protect you in a fall, but only just. You'll know immediately whether a shirt can protect your skin from sticks, branches, and prickers dangling into the trail. If you were going fast enough flying insects may even make an impact, though I can't imagine it'd be terribly painful. 

Shirts do offer some protection from two things: sunburns (and subsequent skin cancer) and bites from insects (potentially carrying disease.) For lightly complexioned people, skin cancer is a huge danger and can develop even without having been sunburned. Insect-borne diseases are also a big deal in most places. Having been treated for Lyme disease, I can attest to the importance of wearing insect repellent and, yes, shirts.

Additionally, that thin layer of material actually keeps you cooler by blocking the sun from reaching your skin - this is the same reason why desert dwelling peoples wear lightweight material all over their bodies. Having a shirt on also keeps you from sweating all over your bike and other gear. 

In terms of etiquette: if you're out in the woods and there aren't many people around, go for it. If you're bumping elbows with people on a multi-use trail, maybe consider some modesty.