I've been intrigued for a long time as to why the Buddha teached the formless jhanas. They are not included in the right concentration classification. Plus, they lead to rebirth in states of ignorance. But I found a sutta I'd like to discuss. It can be found here: http://www.accesstoinsight.org/tipitaka ... .than.html
The crucial passage is: "Then there is the case where a monk, with the complete transcending of the dimension of neither perception nor non-perception, enters & remains in the cessation of perception & feeling. And, having seen [that] with discernment, his mental fermentations are completely ended. Even this much is described by the Blessed One as the attaining of an opening in a confining place, without a sequel."
This seems to be the purpose of teaching the formless jhanas. They lead, step by step, to the attainment of nirodha samapatti. And then, when this state is seen with discernment, it leads to Nibbana.
So what is the relation between nirodha samapatti and nibbana? Or, in a different manner, what is it about nirodha samapatti that is important to realise nibbana?
He turns his mind away from those phenomena, and having done so, inclines his mind to the property of deathlessness: 'This is peace, this is exquisite — the resolution of all fabrications; the relinquishment of all acquisitions; the ending of craving; dispassion; cessation; Unbinding.'
(Jhana Sutta - Thanissaro Bhikkhu translation)