I lock my apartment door every time I leave, even if it's just to go grab my mail or to throw out the trash at the dumpster out in the parking lot, just for the habit of it. If I'm ever out and about and I suddenly worry whether I locked the door when I left or not, I can confidently reassure myself because I *never* go through that door without locking it.
Even in a magical world where robbery doesn't happen (nor any other crimes), it's still a privacy feature - I wouldn't want even my family or best friends coming into my home when I didn't expect them in case I hadn't cleaned up or put away anything I didn't want them to see, etc.
Plus, I've accidentally gone to the wrong door at my apartment complex once when I was entering from a different direction than usual and I stopped one building too soon, since all our buildings look identical, so I was very glad the door was locked and I didn't accidentally wander into a stranger's home. On the flip side, I did accidentally get into the wrong vehicle once because someone parked next to me with the exact same make/model/year car that even had similarly peeling paint on the hood, but they *didn't* lock their car - I hit unlock on my key fob, I actually heard the click of my door unlocking, since mine was just one spot over, and then I opened the wrong door (since it was left unlocked) and sat down in someone else's car, only realizing once I was fully inside that it was far too tidy to be mine.