The theme of the poem 'The Inchcape rock' is 'crime and punishment'.
Let me explain it:
Ralph, the pirate, went on an adventure on the sea with the sailors. He was brave to take the risk of cutting offf the bell from the Inchcape rock. The motive for his wicked deed was jealousy. He could not accept the popularity of the good Abbot and tried to spoil his fame and reputation by cutting off the warning bell.
Since the punishment follows the crime, the poem ends with sir Ralph being punished for his evil deed. The ship struck the inchcape rock and it sank.
The moral lesson was --- 'As you sow, so shall you reap'