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,
Yet each man does not die.

6.13 And all men kill the thing they love,
6.14 By all let this be heard,
6.15 Some do it with a bitter look
6.16 Some with a flattering word,
6.17 The coward does it with a kiss,
6.18 The brave man with a sword.

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
2.50 When Love and Life are fair:
2.51 To dance to flutes, to dance to lutes
2.52 Is delicate and rare:
2.53 But it is not sweet with nimble feet
2.54 To dance upon the air!

so Wilde's despair

2.73 A prison wall was round us both,
2.74 Two outcast men we were:
2.75 The world had thrust us from its heart,
2.76 And God from out His care:

so this is a lament of hopelessness in the face of a merciless, cruel system:

3.187 For Man's grim Justice goes its way
3.188 And will not swerve aside:
3.189 It slays the weak, it slays the strong,
3.190 It has a deadly stride:
3.191 With iron heel it slays the strong,
3.192 The monstrous parricide!

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,
4.138 And outcasts always mourn.

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).