The eponymous ancient mariner was cursed for shooting and killing an albatross. This albatross supposedly brought the ancient mariner and his fellow sailors tremendous good luck. Before the albatross appeared, the sailors' ship was stuck between sheets of ice. The ice "cracked and growled, and roared and howled," and the sailors became afraid that they might never escape. Then, "as if it had been a Christian soul," the albatross appeared, and the ice sheets "did split with a thunder-fit."
However, soon after, for reasons unexplained, the Ancient Mariner decided to kill the albatross. For this, he was cursed. The death of the albatross heralded a long drought which eventually killed all of the sailors except for the ancient mariner, who was cursed to look on helplessly as those around him died but he did not. Additionally, the ancient mariner must forever afterwards "from land to land" to tell his story, as a warning, to other people. Indeed, this is why he narrates the poem to the wedding guest.
The lesson that the ancient mariner wishes to impart to the wedding guest and that Coleridge wishes to impart to his readers is simply that they should respect the natural world. They should not assume that they are more important or in any way better than the creatures of the natural world, such as the albatross.
This poem was first published in 1798, during the Romantic era. Romantic poets, like Coleridge, often celebrated the natural world as beautiful and sacrosanct. Romantic poets believed that God existed in and through nature and that the best way for humans to worship God was, therefore, to appreciate and respect the natural world. The ancient mariner was cursed because, in killing the albatross, he failed to show respect for the natural world.