The Earth's orbit around the sun is controlled by two things. The first is the gravity of the sun, and the second is the way the earth moves sideways in space.
The sun has gravity, similar to the way Earth has gravity. On Earth, gravity keeps everything on the ground and ensures people, animals and other things do not float up into the sky. It pulls objects towards the Earth.
The sun's gravity is similar in that it pulls objects toward it. But, in the case of the sun, those objects are planets. One of the planets is Earth. So, why does the earth not get pulled into the sun?
The reason why planets don't get pulled into the sun is that they are also moving sideways. This makes the planets move in a circular way, rather than in a straight line toward the sun. The circular motion is called an orbit.
If there was no gravity from the sun, the Earth would continue moving sideways in one direction and would float off into space. If there was no sideways movement, the Earth would be pulled into the sun. With the sun's gravity and the sideways movement working together, the Earth moves in a controlled orbit around the sun.