Assume your hash has 15 keys. @_ is a list of all the keys. As an EXPR for rand, @_ is evaluated in scalar context, which results in the number of items in the array (15). rand @_ is like rand 15, which returns an integer between 0 and 14. Say it returns 6. Then, the 7th key ($_[6]) is returned by the sub.
UPDATE: I agree with the reply below that rand does not return an integer.