A function is a relationship between some number of input values and an output value, such that when the function is applied repeatedly to the same input, you always get the same output. Thus, RANDOM is technically not a function, because it can be called twice with the same inputs and get different outputs.
This is a mathematical definition, not an operational one. There's no requirement that a function be computable; in fact, almost all functions are not computable, because the number of possible computer programs is countably infinite (you can number them), whereas the number of possible functions is uncountable. (If you try to number them, even with an infinite number of integers, there will still be functions left uncounted.)
(In fact, almost all functions can't even be described, because there are only countably many strings of characters. This is strange stuff. But don't despair; all the functions that anyone cares about can be described, by explaining why they're interesting.)
The function is the association between inputs and outputs, regardless of how computed. For example, $$f(x)=2(x+3)$$ and $$g(x)=2x+6$$ are the same function, even though they're different algorithms and, if implemented as described, different computer programs. In technical terms, a function is a set of pairs (input value, output value). The set is usually, but not always, infinitely large. (The Boolean operators such as AND are finite sets of pairs.)
You know what a procedure is. Technically, computer programs are always made of procedures, not functions, because the program describes an algorithm, not an abstract association of inputs with outputs. But we computer people generally abuse the language by using the name "function" for a procedure that computes a function. A procedure that, instead, has an effect without returning a value doesn't represent a function, let alone being one.