The person who says, “The coast is clear,” sounds as though he or she is being cautious about avoiding legal detection, and so it should.
It originated as the standard cry from the man in the crow’s nest of every pirate ship before it chanced a landing.
When the captain verified with his telescope that there was no danger in going ashore, he would repeat the cry, “The coast is clear!”
And so it became an order for his fellow smugglers to prepare to land.