the crypts are part of a citadel that was built in 1688 when the infamous pirate henry morgan destroyed the former spanish settlement at panam el viejo , established for the plundering of incan gold .