Making a prefab out of this

Okay I have a simple code of a cube moving back and forth between two points

using UnityEngine;
using System.Collections;

public class MovingDaCube : MonoBehaviour {

	public GameObject Square;
	public float speed;
	public Vector3 pos1;
	public Vector3 pos2;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		transform.position = Vector3.Lerp(pos1, pos2, Mathf.PingPong(Time.time * speed, 1.0f));
	}
}

I want to be able to make a prefab out of the cube so i can place it anywhere i want rather set to two points. how woukd i go about doing this?

You could parent your cube to an empty game object (make the cube a sub-object of the empty), and use transform.localPosition to move the cube based on where you placed the parent object (the empty).

Make pos1 and pos2 Transform types.

In the editor create two empty game objects, make them children of this object.

Drag the two empty objects into the pos1 and pos2 variables in the inspector for this object.

Instead of lerping between pos1 and pos2 use pos1.position and pos2.position

Save this object that now has children as a prefab.

When making instances of the prefab move their child pos1 and pos2 GameObjects (either in the editor or in code) to change the positions the object will bounce between.