St. Joseph was chosen by God to be the defender of the Holy Family, the one who would protect the Virgin Mary and Christ Child from earthly enemies. He was warned by an angel to take his family and flee to Egypt, thus ensuring the Messiah would live until adulthood.
In a similar way, St. Joseph is invoked by many as a spiritual defender, a powerful intercessor against spiritual evils. Just as St. Joseph protected the Holy Family, so too can he protect us on our earthly pilgrimage to Heaven.
Pope Leo XIII wrote an encyclical on St. Joseph, and at the end of it composed a prayer to St. Joseph for protection from evil. The prayer reassures us that we are not alone in this daily battle and that St. Joseph is at our side, ready to help us defeat our spiritual enemies.