The Door appeared in "The Death Of Tristan Taylor". Its purpose is to announce/cause Tristan's imminent death. In the beginning of the episode, he called out for Tristan (who was feeling happy to be alive). When Tristan, Serenity and Duke find the door, it keeps asking them to open it.
Duke asks where the Door would take them, to which the Door answers a World of deep unending pain and torment...and ponies. The Door makes up the lie about the ponies so it could get Tristan into open it. Duke doesn't trust the Door, but Serenity Tristan stupidly agreed, after the Door promised free pony rides to the three of them.