There is a remark in the NIV translation
The earliest manuscripts and many other ancient witnesses do not have John 7:53—8:11. A few manuscripts include these verses, wholly or in part, after John 7:36, John 21:25, Luke 21:38 or Luke 24:53.
Eventually it was put in here should not be a coincident. We can see the narrative before it and after are related to 'Fair Trial'.
Before the incident
Starting from John chapter 7, the narrative told Jesus went to Jerusalem for the Festival of Tabernacles, and was teaching people in the temple courts. His teaching was such an inspiration that even the temple guards who sent to arrest Jesus failed to accomplish their mission. Opinion split amongst people and some Pharisees called Jesus and His disciples 'a mob that knows nothing of the law' (John 7:49). But Nicodemus, who had met Jesus responsed “Does our law condemn a man without first hearing him to find out what he has been doing?” (John 7:51)
After the incident
From John 8:12-20, Jesus declared He is 'the light of the world'. Jesus said
17 In your own Law it is written that the testimony of two witnesses is true.
18 I am one who testifies for myself; my other witness is the Father, who sent me.” (John 8:17-18 NIV)
The incident
It may be interested to note that in chapter 7, John described Jesus inspired people by words, and now facing the challenge of the Pharisees, who intended to prove Jesus knew nothing about the law, Jesus kept silent in response but writing something on the ground. The scripture didn't record what exactly Jesus wrote, but from His established influence in people, Jesus might have wrote something strong enough to push back the people from their original desire.
The narrative described the woman who caught in adultery, was brought forward by her accusers - the teachers of the law and the Pharisees, who claimed be the witness, and the man who be with her, supposed to be the second witness, didn't existed. The group surrounding should have been reminded, that this Trial was deficient in evidence.
What Jesus wrote should have reminded people that 'Judgement belongs to God' (Deu 1:17) - This echoes to Nicodemus response (John 7:51) and Jesus claimed (John 8:18). His writing alerted the elderly people faster, that John described 'they went away one at a time, the older ones first' (John 8:9).
What Jesus had wrote on the ground?
In my opinion, may not be word, but drawing, snakes. Jesus was drawing a snake on the ground, and another snake, and snakes. The public particularly the elders were suddenly aware of Jesus implying Psalm 58, it wrote;
1 Do you rulers indeed speak justly?
Do you judge people with equity?
2 No, in your heart you devise injustice,
and your hands mete out violence on the earth.
3 Even from birth the wicked go astray;
from the womb they are wayward, spreading lies.
4 Their venom is like the venom of a snake,
like that of a cobra that has stopped its ears,
5 that will not heed the tune of the charmer,
however skillful the enchanter may be.
6 Break the teeth in their mouths, O God;
Lord, tear out the fangs of those lions!
7 Let them vanish like water that flows away;
when they draw the bow, let their arrows fall short.
In ashame of being the judge and afraid of revenge from the Lord, they went away.