Wilde's poem has echoes of his own specific experience being jailed (essentialy) for homosexuality. So its relation to spiritual or religious values in in question. the famous tag line is
For each man kills the thing he loves,
6.13 And all men kill the thing they love,
The peom traces the love of the moment in the convict who will hang for killing his lover.
There is an allegory here about the way those in the society are killing the spirit but don't recognize it and so can't experience life as this (new) convict can.
It has a Tennyson feel.
An elegy for an era/error.
You have the quick turn from gaiety to nightmare (a gay life to gallows) --
2.49 It is sweet to dance to violins
so Wilde's despair
2.73 A prison wall was round us both,
so this is a lament of hopelessness in the face of a merciless, cruel system:
Wilde is very much aware that each of us, of the prisoners, has committed unforgivable sins, but not the sin here, what he calls "the killing of the dead" and sinning "a second time." For the prison is even lost to Christ's grace, unholy ground, as the dead man, though a sinner, is not treated with grace.
4.137 For his mourners will be outcast men,
Society is seen from the vantage of a prison cell, and the outcasts/prisoners the ones for whom Wilde mourns. As for the the incarcerated, well we still have those with us . . .
Finally, for Wilde "sorrow" -- he called this poem a cry of the heart -- is an aesthetic principle that creates a powerfully autonomous work, for its own sake; that is, the poem that is of, by, and for sorrow is entirely aestheticized (as art for art's sake, sorrow for sorrow's sake).