Hey and welcome,
The mouse is in a 2D (camera) system which is not at all related to any 3D space in the scene. This system describes the mouse position on the screen between (0,0)(upper left corner) and (1,1)(lower right corner).
Luckily for us unity has an integrated function to turn this into a screen point by using a raycast. Normally since the camera is normally perspective you would not be able to just draw a straight line from the screen outwards and hit the right gameObject in the scene.
That being said you can do a "screen pick" from your screen coordinates or just use a "mouse pick", which always uses the mouse as the start of the ray.
Then you save to hit point and set the position of your cube to that hit point. If you do this every frame, the cube will follow your mouse while being stuck on the ground.
Note: If your cube has a collider it instead of the floor would be hit by the raycast. So make sure to put it into a new layer and then use an inverted layer mask on your pick action. That will make it ignore everything in that layer.