The Camino, and Spain in general are very safe.
However, it is important to take precautions with our valuables. That means money, credit cards, your passport, your pilgrims credential, and any electronics or cameras. So what do we mean by precautions? That means that you should NEVER let these things out of your sight. You take them with you to the bathroom in the middle of the night, you take them into the shower, and you take them with you everywhere you go at all times.
Violent crime is very rare on the Camino but property crimes happen. The best way it has been described is that if you would not leave whatever it is on a table in a food court in the US and walk away from it don’t leave it in Spain. All of that being said it should be perfectly OK to leave your backpack in the Albergue while you go out for dinner, sightseeing, or shopping so long as you remove the valuables from it. No one is going to steal your clothes or underwear.
Make sure that you have some type of waterproof container, such as a large ziplock bag with you so that you can take your valuables into the shower with you.
So far as personal safety is concerned. You just need to pay attention to your surroundings. Spain is a safe place, especially the Camino but of course, things happen when we get careless.
Your biggest concerns in large cities such as Madrid and especially Barcelona are pickpockets. This is an art form and caution is warranted. It is best to keep your valuables in a fanny pack or crossbody bag that is zipped closed. When sightseeing it is best to keep your daypack close at all times. It is better to wear it on the front. Never leave it just hanging over the back of your chair or on the floor under your seat in a restaurant you risk having it disappear.