Margaret Thatcher's choice of William Wordsworth's Ode: Intimations of Immortality from Recollections of Early Childhood to be read aloud at her funeral service is remarkable – and surely both heartfelt and carefully considered.

Wordsworth's Ode is a complex mix of mournfulness and delight, almost joltingly appropriate for the occasion. At its heart is the extraordinary image of a child playfully imagining adult life and its culmination in a funeral. The poem ends by invoking "the faith that looks through death", but begins as an expression of disillusion. "The things which I have seen I now can see no more ... Whither is fled the visionary gleam?" The poet reaches back into childhood for this lost "gleam", beyond "the light of common day", and only just detects it.

Wordsworth, a radical in his youth, was to become a devout Anglican and Tory in older age, but the Ode was written before this transformation. It was finished in 1804, at the same time that he was completing his magnum opus, the 1805 Prelude. This epic poem is now regarded as thoroughly pantheistic: it finds divinity everywhere in the works of nature, but shows little interest in a Christian God. Those "Intimations of Immortality" in the Ode are comparably unconventional, owing something to Plato but nothing to the Bible.

God is in the poem, certainly, but seen best in childhood, whose "simple creed" is "Delight and liberty". The "Mighty Prophet" of the poem is an infant, on whom custom does not yet lie "Heavy as frost". Wordsworth audaciously uses religious vocabulary – "blessing", "benediction", "song of praise" – in utterly unexpected ways. It is not what one would expect from Margaret Roberts's strict Methodist background, about which we are so often told. Perhaps her religious feelings were not so hampered.

She must have come across the Ode as a child or teenager. It may have been a text at Kesteven and Grantham girls' grammar school to learn by heart and perform. It was a core poem in Palgrave's Golden Treasury and every other anthology of verse likely to be found in a school library in the 1930s. It is metrically complex, yet Wordsworth's rhythms are inescapable. Full of brilliant phrase-making – "trailing clouds of glory", "like a guilty Thing surpriz'd", "splendour in the grass" – it is irresistibly quotable.

If it did stay with her from youth, what better reason to have it read at her funeral? For it is a poem that recalls childhood with pained wonder, ending on "Thoughts that do often lie too deep for tears".

Denis Healey said that Mrs Thatcher, whose life seemed all politics, had no "hinterland", but perhaps this is a glimpse of it.