The foundation of safe cities is vibrant local communities with historic roots. Parts of the city where people choose to have and raise kids. Places with a sense of shared community where neighbors look out for each other.
The rapid influx of extremely high income individuals transformed SF over the course of the last decade. Uprooting those communities and replacing them with largely transient techworkers with no real interest in forming communities that don't help them to increase their TC and level up with their next new role.
Then when tech declines you really see the impact this has.
SF was treated as basically a luxury mall for rich tech workers to get whatever they want whenever they want. As tech workers start to leave it's no wonder the city feels like an abandoned mall.