This is where the map, in combination with the Invisibility Cloak, became useful. Moreover, in order to become Animagi to begin with, the Marauders needed to do a lot of sneaking around. Once James, Sirius, and Peter had become Animagi, they could wander the Hogwarts grounds without raising suspicion-but that wasn't the case within the castle walls. Instead, the desire to be with their werewolf friend, Remus Lupin, revealed the need to have a thorough understanding of Hogwarts Castle. However, the Wizarding World website explains that the simple joys of trouble-making weren't the primary reason James and Sirius thought to create their map. Ultimately, this is precisely why the Marauders invented it.
During the days of Harry Potter, the Boy Who Lived frequently wandered Hogwarts Castle at night, and obtaining the Marauder's Map made this rule-breaking much easier.