This reminds us that we too are safe when we are within God's will. They momentarily forgot that Jesus was carrying out the will of his true Father - God in heaven. Doing his Father's will never posed a threat, even though Mary and Joseph had been afraid that something bad had happened to Jesus when they couldn't find him. When we are living according to God's Word and will for us, then come what may, we have nothing to fear. As those who belong to God in our baptism we have nothing to fear even when we're afraid.
Fear is often the consequence of sinning.
When a Christian sins and temporarily steps outside of God's will, anxiety and fear often increase. By his sinful actions the Christian can wound his confidence that he is living safely within the will of God. Doing something intentionally against our conscience often momentarily loses this confidence that God is for us. But as soon as we repent of our sin and trust Christ we can quickly regain the confidence that God is for us and that we have nothing to fear. Oh, we can be injured, suffer outward misfortune, or face the loss of a loved one.