“Fear not” is one of the most repeated commands in the Bible, and it almost always comes with a reason: God is present. Scripture does not promise a life without threats; it promises company in the middle of them.
Have not I commanded thee? Be strong and of a good courage; be not afraid, neither be thou dismayed: for the LORD thy God is with thee whithersoever thou goest.
Spoken to Joshua before a task bigger than himself: courage is commanded because presence is guaranteed.