A recent article by Charles M. Stang (*) notes that "Thomas's acclamation [in John 20:28] is the only place in the New Testament where Jesus is called 'God'."
I think that's pretty remarkable. Elsewhere Jesus is called Son of God, image of God, and other similar epithets, but only here is he plainly "God".
More remarkably, the declaration by Thomas is not an abstract philosophical idea but a personal commitment, for the full exclamation was "My Lord and my God!"
What caused the famous doubter to make such a bold avowal? Stang suggests that it was not because the doubts about whether Jesus was alive were removed when Thomas touched him. In fact Thomas probably did not touch Jesus! Jesus invited him to but the declaration "My Lord and my God!" comes immediately after the invitation, with nothing at all to imply that he touched Jesus first.
It strikes me that the Gospel writer has created a clever parallel between this scene at the end of the Gospel and one at the beginning – with Nathanael back at the end of chapter 1.
Nathanael is sitting under a fig tree when Philip says to him "Come and meet Jesus of Nazareth. We think he might be the promised one." to which Nathanael responds derisively "Not likely if he comes from Nazareth!" But he came to Jesus anyway and Jesus surprises him by already knowing what he was doing under the fig tree. More than that, Jesus affirms Nathanael's guileless heart.
In response to this surprise of being known, Nathanael blurts out “Rabbi, you are the Son of God! You are the King of Israel!”
The parallels with the Thomas scene are numerous. Thomas is also told about Jesus by other disciples and he responds derisively. But when he meets Jesus, he finds that his thoughts are already known to Jesus. And in the surprise of being known he blurts out "My Lord and my God!" To end both scenes, Jesus is recorded as commenting on the basis for belief.
At the beginning and the end of the Gospel, John records people making life-changing allegiances to Jesus because they are surprised and overjoyed to realise that they are already known by Jesus. The significant thing about this kind of faith is not how it is influenced by what you know or how much you doubt. What is significant is that faith – or faithfulness – is based on a certain kind of relationship. In neither Nathanael's nor Thomas's case does Jesus reprove them for doubt, and I am sure both continued to hold doubts. So it's not that they made some declaration of faith because their doubts went away. Rather, they both made declarations of allegiance because in being known by Jesus they recognised the compassion of God.
* Stang, Charles M. 2016. “Doubt, Our Modern Crown of Thorns.” Studies in Church History 52.