I can think of three different approaches to your problem. One involves using an object silhouette or shape as a preview of where it's going to be placed; another is a real-time positioning of the object, providing interaction with surrounding instances; the last one is again real-time positioning though by computing the last valid position.
This method allows the user to place the cube in your 3D space by instantiating sort of ghost version of it (e.g. making it look translucent) and moving it around with the mouse, showing where user is going to actually draw it, like if they were using a brush.
All positions are valid for the brush preview, as long as no other objects are intersected; illegal coordinates will highlight the brush model in red hue, for example. You can check if a given position is valid with a simple AABB collision detection algorithm, given axis-aligned cubes.
Clicking a valid position will create a new instance of a cube, allowing the user to instantiate more.
Follow mouse method #1
With this method you create an actual cube in the first valid position using raycasting at creation only. Next, the cube will try to move as close as possible towards the position in space pointed by the cursor arrow, taking into account collisions with other object.
This way, the cube will be placed in the best possible position with respect to mouse position, being never misplaced since collision detection is active and the cube starting position is valid by definition.
To accomplish such behaviour you must check if the mouse position is a valid position for the cube. If so, place the cube there; otherwise, move the cube as close as possible to the mouse position, taking collisions into account.
Follow mouse method #2
Similar to the previous one, but if the current mouse position is not valid for the cube, place the cube there and then push it outside from any other instance it may be intersecting with. More tricky, but better results than the first variant.
Last valid position method
This is pretty much the Follow Mouse #1 method, but you update the cube position only when the mouse position points to a valid place for the cube; otherwise, the cube stands still.
Concerning implementation, all these methods require only collision detection to make sure cubes don't intersect, not a heavy workload for the CPU since AABB is quite simple and fast. Raycasting is used once only, by one single method. Colliders can be a solution, but you can write your own AABB collision detection algorithm (Jonathan Whiting's tutorial, at "Detecting Rectangle Collision) without the need to import that library, and dealing with such a simple collision tecnique on your own.