Changing speed on run time in script makes attached object act weird C#

I found this script on another UnityAnswer.
It is a script that let an object (where this script is attached to). Move in between point A and B. In this script defined as pos1 and pos2.

But there is something about this script that bothers me, When changing the variable speed on runtime. To like 2f; The object will re-position itself to a new location. It doesn’t just only change the speed but it also changes the position of the gameObject.

My question : Why does it do this.

public class Example3 : MonoBehaviour {
     private Vector3 pos1 = new Vector3(-3,3,0);
     private Vector3 pos2 = new Vector3(3,3,0);
     public float speed = 1.0f;
 
     void Update() {
         transform.position = Vector3.Lerp (pos1, pos2, (Mathf.Sin(speed * Time.time) + 1.0f) / 2.0f);
     }
 }

Because what you call the speed (the third argument of lerp)is actually a percentage between pos 1 and pos 2. Try to use transform.position instead of pos1 and you’ll see it works. Problem doing so is the lerp will slow the more it reaches the end.

See this wonderfull article for how to do proper lerps: Using Vector3.Lerp() correctly in Unity — One Man's Trash is Another Man's Blog