Snapping two objects by edge in Object Mode
Select one cube, then enable the snap during transform option (click on the magnet icon), change the snap element to Vertex and snap target to Closest. Move the cube (G) along X,Y and Z axis until it snaps to the proper place.