object doesn't moves but its transform keeps changing

Hello I am new to unity And trying to move an cube Object in x direction so I wrote a simple code.

private Rigidbody rb;
public float forwardSpeed;

// Use this for initialization
void Start () {
    rb = GetComponent<Rigidbody>();	

}

// Update is called once per frame
void Update () {

    ///moving in X direction

    Vector3 moveForward = rb.velocity;
    moveForward = new Vector3(forwardSpeed, rb.velocity.y, rb.velocity.z);
    rb.velocity = moveForward;
}

when i play it the cube doesn’t move ,but in inspector panel its X and Z transform component keeps changing even though the forwardSpeed is set to 0 . The component values keep changing back and forth from -1 to -8 and when i set forwardSpeed to 5 the cube rotates and moves in x direction and falls down.plzz Help I cant figure it out why that’s happening.

Unity advises against modifying Rigidbody.velocity directly. Have you tried just moving it without physics?

void Update () {
     ///moving in X direction
     Vector3 currentPosition = this.transform.position;
     currentPosition.x += this.forwardSpeed * Time.deltaTime;
     this.transform.position = currentPosition;
 }

You are using Update(). But physics calculation is done in FixedUpdate(). Those are done in different framerate. And the rotation is caused by the friction of the floor. If you don’t need to do complicated physcis mechanic. Just use CharacterController instead Rigidbody