Suppose a asteroid in deep space and there is nothing around it to compare it with. My question is how would you known that the asteroid is moving if there is nothing to compare it with
Your question seems simple, but it cuts directly to the heart of the principle of relativity, which is to say: Every non-rotating frame of reference is equally valid. It doesn't even matter if there IS something nearby to compare with. All motion is relative. There is no zero-point somewhere against which motion can be measured.
You can measure whether the asteroid is moving relative to yourself (or your detection equipment, at least), but let us assume you are not moving relative to the rock -- let's say you're standing on its surface.
You could observe the apparent movements of the stars and galaxies, and it may take a very long time, but you could in theory observe that they move relative to one another over time in a way that is consistent with your asteroid floating through space -- but it's equally consistent with those stars and galaxies being in motion while you stay still.
Suppose another rock comes floating past. Does that tell you anything? Not really. With no external reference frame, it's equally valid to say you're stationary and the rock is floating past, or to say the rock is stationary and you're moving, or to pick some arbitrary frame that's between the two so that you're both moving in opposite directions.
You could possibly observe that the stars in one direction are red-shifted more than the stars in the opposite direction, and from that determine that you are in motion relative to those stars, but again it's equally consistent to determine that the stars on one side of you are just moving away faster than the ones on the other side.
So yes, there are ways to measure distant stars to determine that motion is occurring, but there's no way to distinguish whether that motion is happening to you because it's all relative.
There are 3 important things to take an measurement, observer and or frame of reference and object (frame of reference does not necessarily mean the observer, it is the co-ordinates system that an observer uses to find out the position). Everything is relative to an observer, if there is no observer, there is no measurement
We need to have a frame of reference to compare something, without an observer it is not possible to get the speed
For example, using radar we measure distance, but where the light rays of radio frequency is emitted, is the observer, the frame of reference. Quantum mechanics even states that without an observer, the object does not exist
In case of an DSO like an asteroid, all the methods through which we may determine the velocity are observer-dependent (which means not only does it require a frame of reference/observer, the observer also influences the result. E.x according to a red car moving at 31 kmph and another yellow car moving at 21 kmph, the velocity observed by the yellow car is 10kmph of the red car). For example, the parallax method, herein we align the object with our line of sight to find the velocity, but this too requires an observer through which the line of sight is observed.
Thank you, hope it helps you!