transform.position.y

I warmly welcome
I have a problem with comparing transform.position.y terms previously generated transform.position.y
sorry for my English

GetComponent<Rigidbody2D>().velocity = velocity;
        transform.position = new Vector3(transform.position.x, transform.position.y - range * Random.value, transform.position.z);
        Debug.Log (transform.position.y);

Do you want to know how transform.position.y has changed since the last frame?

float previousY;

void Start()
{
    previousY= this.transform.position.y;
}

void Update()
{
    float deltaY = this.transform.position.y - previousY;
    // do stuff with deltaY
    previousY= this.transform.position.y;
}

checking if the other is below or above the first and the third higher or lower second and so on

:eyes: euh… yes?..

Y(t) => this.transform.position.y.
Y(t-1) => previousY

delta Y => Y(t) - Y(t-1)

You want to compare the object by height?
Just use subtraction.
For example, if you want to compare one vs two:

Delta1_2 = Y1 - Y2

if Delta1_2 > 0, it means 1 is higher than 2
if Delta1_2 < 0, it means 1 is lower than 2
if Delta1_2 = 0, 1 and 2 are at the same height