Unrealistic physics. Placing cubes on each other.

If i place 30 rigidbody cubes on each other, they start shivering, bouncing off each other and finaly fall on the floor.

You can see this effect using this Unity script:

function Start () {
        for (var y = 0; y < 5; y++) {
            for (var x = 0; x < 5; x++) {
                var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.AddComponent(Rigidbody);
                cube.transform.position = Vector3 (x, y, 0);
            }
        }
    } 
  1. Create floor
  2. Create an empty object
  3. Attach the script to the empty object
  4. Change “y < 5” to “y < 30”

The question is: how to make it behave like in real world?

Change the code a bit:

cube.AddComponent(Rigidbody).Sleep();

you need to change the collision detection on the cubes, however i would still listen to eric5h5 as this method is a more costly approach, but in any case here is the edited code.
and some explanination on rigidbodies Unity - Manual: Rigidbody component reference

#pragma strict

function Start () {
        for (var y = 0; y < 5; y++) {
            for (var x = 0; x < 5; x++) {
                var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.AddComponent(Rigidbody);
                cube.transform.position = Vector3 (x, y, 0);
                cube.rigidbody.collisionDetectionMode = 2;
            }
        }
    }