Asteroids are objects that orbit the Sun, just like other planetary bodies such as planets and moons. They are not "floating" in space in the sense of being stationary or suspended without any gravitational influence. The reason asteroids remain in orbit around the Sun rather than simply floating away or falling into it is due to the dynamics of gravitational forces.
Gravity plays a crucial role in determining the motion of celestial bodies. When an object, such as an asteroid, is in space, it experiences gravitational attraction from nearby massive objects, primarily the Sun and other larger celestial bodies. This gravitational force acts as a centripetal force that keeps the asteroid in a stable orbit.
The motion of an asteroid in orbit is a delicate balance between the gravitational pull of the Sun and the centrifugal force generated by the asteroid's velocity. As long as the gravitational force pulling the asteroid inward is balanced by the centrifugal force pushing it outward, the asteroid remains in a stable orbit.
If an asteroid were to lose its velocity or be subjected to a strong gravitational influence from a nearby massive object, it could be pulled out of its original orbit and either collide with another body or be flung into a different trajectory. Some asteroids can also be perturbed by the gravitational influence of planets, causing their orbits to change over time.
In summary, asteroids do not float aimlessly in space but instead follow orbits around the Sun due to the gravitational forces acting upon them. It is the interplay between gravitational attraction and the centrifugal force that keeps them in their respective orbits.