Google Sheets Function: RAND
The RAND function generates a random number in the range from 0 to 1 (1 being excluded).
Usage:
=RAND()
Usage Examples
Using the RAND function alone generates a decimal number ranging from 0 to 1 (excluding 1):
=RAND()

It's also possible to modify the range from "0 to 1 (excluding 1)" to, for example, "10 to 50 (excluding 50)".
The formula then becomes (40 = range of values, 10 = starting value):
=RAND()*40+10

To generate a whole number within a defined range, simply use the RANDBETWEEN function.