On a personal level, an unexpected interaction can lead to meeting friendly people. You may even get some unexpected "reward" out of it: say maybe a neighbor was knocking to see if they could borrow your car, maybe the same neighbor has some plumbing skills and notices the leak in your kitchen, and proposes to fix it for you.
On a societal level, unmediated interaction between strangers is very important for social life and a sense of community. Please note there is a huge difference between unsollicited contact and stalking behavior: a person knocking on your door to ask something is certainly not in the same mindset than someone following you home.
So sure there's scams and salespeople. But if you don't open the door to those, you'll miss plenty of friendly interactions as well. At this point, better not check your email or phone because there might be spam there too?
As it happens my street has a confusing layout which means I get lost food drivers at least twice per month. It only takes a moment to direct them to the right house.
By which I mean, I don't think I've ever gotten any of those latter three, and have dealt with a couple of the former. (Mostly drunk men in the middle of the night, so I totally understand why some people wouldn't want to answer the door in that situation.)