How to smoothly rotate the object?

The object is rotated using the buttons

            if (touch.position.x < middle && touch.phase == TouchPhase.Stationary)
            {
                ballGameObject.transform.Translate(new Vector2(-1f, 0f) * 20f * Time.deltaTime);
                groundGameObject.transform.Rotate(new Vector3(0f, 0f, 1f) * 20f * Time.deltaTime);
            }
            if (touch.position.x > middle && touch.phase == TouchPhase.Stationary)
            {
                ballGameObject.transform.Translate(new Vector2(1f, 0f) * 20f * Time.deltaTime);
                groundGameObject.transform.Rotate(new Vector3(0f, 0f, -1f) * 20f * Time.deltaTime);
            }

Suppose I have an object is rotated by 30 degrees. How smoothly poverut it to 0 degree?

You could use Lerp, Or LookAt But in your case i’d recommend Lerp.

With this code I object rotates instantly.

groundGameObject.transform.rotation = Quaternion.Lerp(transform.rotation, transform.rotation, Time.deltaTime * 1);

Many have tried and does not work.