How to move a cube to another cube

How to move a cube to another cube when I click the cube.

When I click cube1 I need cube1 to find the position of cube2

Then I need cube1 to go to cube2.

I looked for answers on this but none were easy for me to understand sorry.

You can set up a Raycast to detect when the mouse clicks on the cube, then set the transform.position of cube 1 to cube 2.

	public Transform cube1;
	public Transform cube2;
	
	void Update () {
		RaycastHit hit;
		
		if(Input.GetMouseButtonDown(0)){
			Ray _Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			if(Physics.Raycast(_Ray, out hit, 100f)){
				GameObject hitObj = hit.collider.gameObject;
				if(hitObj.tag == "cube 1"){
					cube1.transform.position = cube2.transform.position;
				}
			}
		}
	}

Here is a script that does not involve Raycasts. It moves the object immediately (not over time). If both objects are the same size and shape, then the moved object will seem to disappear (since they are at the same position).

using UnityEngine;
using System.Collections;

public class MoveObjectTo : MonoBehaviour {
	public Transform transDest;  // Destination 
	void OnMouseDown()	{
		transform.position = transDest.position;
	}
}