Choosing accommodations where both you and your belongings are safe from theft or other potential harm should be the bare minimum criteria each traveler has, whether backpacking or staying at a five-star hotel.
Obviously, there will always be some degree of uncertainty, but conducting a quick evaluation of an accommodation and packing a few extra items for "just in case" scenarios can help reduce some of the more predictable risks.
Staying in a comfortable place (in the material sense) where you can properly unwind and get a good night's sleep is also important, but less crucial than the safety aspect. In my mind, if a room is safe, clean, secure, and I feel like I could get a good night's sleep in it, I'll take it.
Keeping in mind both sets of criteria, I've come up with a few accommodation-related tips and hacks that have come in handy for me on my solo travels. Many are based on common sense while others might not be so intuitive and require being resourceful in the moment. This list will be updated periodically as I travel and think of new little tidbits to share.
Choosing a Room
Before committing to a room, ask to see one (or several), and check for the following:
A door that locks securely from the inside and has a keyed entry. Sometimes one or the other (or both) isn't an option in homestays/guesthouses, but in theory, accountability should be higher in private residences, where hosts want you to give them positive feedback (e.g., Airbnb, Couchsurfing, etc.). If you have to compromise on a door lock for the sake of convenience, bring a door stopper and wedge it behind the closed door overnight as you sleep. And if other guests are staying in the house and you're hesitant to trust them, better keep your valuables on you when you're out or ask your host if they can store them elsewhere for safekeeping. Some hotels will store your valuables in a security box for a fee.
Windows that can be securely closed/locked (and ideally have screens). This is more of a security issue on the ground level of a building, but keep in mind that open, screenless windows are an entry point for mosquitoes and other insects, so it's especially something to consider if there is no mosquito net in the room.
A safe-looking neighborhood. Who's on the streets? Are other obvious tourists out and about, or is it sketchbag central? Ladies: are there other women around? (Note that in some conservative, patriarchal countries, women are a rare sight in public places, so this gauge may not be applicable.) Is the accommodation gated and/or is there a security guard on the premises? Unfortunately, neither a gate or security guard are foolproof barriers, so don't rely on them to keep you safe. If you've never visited a place, it can be hard to know by visual inspection alone where the shady places are, but asking the locals or doing some rough Googling beforehand should provide some reliable insight.
Clean sheets/bedding. Have a quick look at the bedding and pillows. If you want to go one step further (I don't), you could check for bedbugs by looking at the mattress. If you're ever in doubt and can't or don't want to look for another room option, spread your sleeping bag and/or travel sheet (I pack both) on top of the bedding as a barrier.
Laundry facilities. This point only becomes relevant if the timing of your stay coincides with running out of clean clothes. Unless you're camping or planning to handwash your clothes and hang them outside on a balcony or inside the room on a clothesline (note that not all accommodations allow this), ask if your accommodation has a laundry service or washer/dryer. For me, having nearly no underwear (or socks for my sneakers) dictates my need for laundry (so I always bring more of these than other piece of clothing). I care less about washing pants, shirts, sweaters, etc.
Mosquito net. Especially if you're staying in a tropical area where mosquito-borne diseases are prevalent, you'll want a room that provides a net (one that is intact) over the bed (unless you've brought your own). If you have your own, check to see if there's a hook overhead for hanging it and test your net to make sure it drapes snugly over the bed.
Maximize Your Shut-Eye
If possible, request a room facing away from the street to minimize noise, especially if the accommodation is located on a main road. Bring ear plugs (or wear ear buds) to shut out noise when you're trying to sleep or relax. An eye mask is also helpful if streetlights and car headlights are shining into your room overnight. A next-level noise consideration is mosques and temples, which sometimes broadcast chanting/preaching over loudspeakers at odd hours of the day and night (no rest for the wicked?). If you're a light sleeper and happen to notice one near a prospective accommodation, you might want to choose another place to rest your weary head. I've haphazardly chosen rooms beside mosques more than a few times by now, so trust me on this one.
In the Room
When traveling in a developing country, take your expectations down a few notches, especially on the aesthetic front. Even mid-range accommodations can be very basic. Obviously, if the ceiling is starting to crumble, mold is growing everywhere, or there are visible traces of rat/mouse poop (cockroaches are also a definite no-go for me), maybe skip it. But if the hot water heater is dysfunctional and the bathroom fixtures are crooked and wobbly, maybe suck it up. Neither of these things compromise your safety.
If you discover holes in your mosquito net and you don't have tape on hand, stuff the holes with Kleenex or toilet paper (or maybe even use band-aids if you can spare a few). Although I've never used it, multipurpose screen repair tape could be a good thing to pack, especially if it's a camping trip where you rely more heavily on your mosquito net.
Only unpack what you need and put things back exactly where you packed them. This will help you keep track of your belongings, prevent you from leaving something behind, and allow you to quickly notice if something has been stolen. I never use the room furniture to store clothes or other items unless they're in plain view (i.e., I don't have to open a drawer or cupboard or stand on my tiptoes to find something). For a longer-term stay, it makes more sense to settle in, but for a night or two, this strategy works well.
It might seem obvious, and it's ultimately your call, but don't tell strangers where you're staying. You could either flat out refuse to tell someone or be vague about it, saying something like "near the bus station" or even "I don't remember the name of the place" or "with a friend." I tend to be okay with telling other friendly foreigners I befriend this information if it comes up, but use your own discretion.
Keep a headlamp or mini flashlight beside your bed in case of a power outage (or if you're staying in a place with no electricity to begin with). In Africa, where outages are business as usual, I guarantee that an extra light source will not be dead weight. A smartphone flashlight would obviously also work in this situation, if you prefer.