“Go away. The girl is not dead but asleep.” (Matthew 9:24)

Here is the situation:
While he was saying this, a synagogue leader came and knelt before him and said, “My daughter has just died. But come and put your hand on her, and she will live.” (Matt. 9:18-19)

When Jesus entered the synagogue leader’s house and saw the noisy crowd and people playing pipes, he said, “Go away. The girl is not dead but asleep.” But they laughed at him. After the crowd had been put outside, he went in and took the girl by the hand, and she got up.
(Matt. 9:23-25)

Why did Jesus heal the girl?

And why didn't Jesus just heal everyone?

The healing of the girl was not Jesus’ mission. If it was, Jesus would have set up hospitals. He would have become a doctor or otherwise a mass healer and had everyone line up so he could touch them and heal everyone.

Rather, his mission was to broadcast his teachings to the masses. How did he - or rather the Supreme Being - accomplish this?

As for the premise that Jesus was just having mercy on people - this is not necessarily wrong, but it is not complete. If Jesus' purpose of healing this girl and a few others was strictly due to mercy, why didn't he heal everyone? Why didn't he focus on healing everyone by setting up hospitals where everyone who was sick or had any physical problem could come and touch him and be healed?

Furthermore, why didn't Jesus heal everyone in the future? Certainly, his healing abilities had no restrictions. He could have healed everyone, right? Why didn't he - if his purpose was to help others' bodies. Why did Jesus leave so many unhealed?

Firstly, because suffering is part of our temporary physical experience, aimed to teach us and provide consequences for our previous activities.

And secondly, because Jesus and God had another purpose in mind:

His healings brought attention to his teachings.

Today there are many ways to broadcast information to the masses, including television, radio and the internet. These mediums did not exist during Jesus' time. During Jesus' time, word of mouth was the central means of broadcasting.

This event illustrated that Jesus and the Supreme Being utilized this to help spread Jesus' teachings by attracting people - even into the future as we are today:
News of this spread through all that region. (Matt. 9:26)
This indicates that his healings brought Jesus attention from the masses.

And what was the essence of his teachings? When Jesus was asked what the most important commandment was, he answered:
"Love the Lord your God with all your heart and with all your soul and with all your mind and with all your strength. This is the more important commandment." (Mark. 22:27-28)