How can I move an object with mouse movement?

Hello, all! I am trying to move a cube with mouse movement.
Left and Right, and Up and Down.

When I try to do this it stays in a small bounding box, as well as clips through the ground.

My game needs the player (cube) to avoid incoming objects and obstacles (including the floor)

using UnityEngine;
using System.Collections;

public class MouseControl : MonoBehaviour {

    // Mouse Control Variabbles
    public float mouseSensitivityX = 1;
	public float mouseSensitivityY = 1;
    
    
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
        
        float moveLR = Input.GetAxis("Mouse X") * mouseSensitivityX * Time.deltaTime;
        float moveUD = Input.GetAxis("Mouse Y") * mouseSensitivityY * Time.deltaTime;
        
        Vector3 mouse = Camera.main.ScreenToViewportPoint(Input.mousePosition);
        transform.position = new Vector3(mouse.x, mouse.y, transform.position.z);
        
        //Camera.main.ScreenPointToRay(Input.mousePosition);
        //Vector3 mouse = Input.mousePosition;
        //mouse = mouse;
        //transform.position = Camera.main.ScreenToViewportPoint(mouse);
	
	}
}

The commented out sections are from previous attempts at my problem.

Many thanks guys and girls.

try this code :

public class MousePos: MonoBehaviour {

    public float speed = 10f;
    public Vector3 targetPos;
    public bool isMoving;
    const int MOUSE = 0;
	// Use this for initialization1
	void Start () {

        targetPos = transform.position;
        isMoving = false;
	}
	
	// Update is called once per frame
	void Update () {
	
        if(Input.GetMouseButton(MOUSE))
        {
            SetTarggetPosition();
        }
        if(isMoving)
        {
            MoveObject();
        }
	}
    void SetTarggetPosition()
    {
        Plane plane = new Plane(Vector3.up,transform.position);
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        float point = 0f;

        if(plane.Raycast(ray, out point))
            targetPos = ray.GetPoint(point);
        
        isMoving = true;
    }
    void MoveObject()
    {
        transform.LookAt(targetPos);
        transform.position = Vector3.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);

        if (transform.position == targetPos)
            isMoving = false;
        Debug.DrawLine(transform.position,targetPos,Color.red);

    }
}

transform.position = new Vector3(mouse.x, mouse.y, transform.position.z);

Did you mean to ‘add’ to the position here, rather than just setting it? It seems like that might be the problem.