The story
From moral (“of or relating to principles of right and wrong in behaviour; conforming to a standard of right behaviour”) + compass (“device used to determine the cardinal directions”), from the fact that a compass indicates various directions on its face (sense 3), and enables its user to find the correct direction to go in (sense 1).
Etymology from Wiktionary, CC BY-SA 4.0.