The purpose of locking doors where I live, at least (San Francisco) is to prevent street people from coming in and sleeping in your hallway, and protect your stuff against petty theft by fairly desperate people who will try doorknobs looking for stuff they can quickly grab.   Locks are quite practical solutions for both problems.