Is teaching a child to fear something (like strangers) a good idea?

Not exactly. It is important to teach children boundaries and safety. Hopefully we do not have to teach them to be afraid. I prefer to use the term empower them with skill sets. Giving them facts that teach why they should not do something is important. Ex: many strangers are simply friends we haven't met yet and some strangers do not have our best interest at heart - check with parents before talking to them.