A relation is any set of ordered pairs, where each pair consists of an input (typically called the domain) and an output (called the range). A function, on the other hand, is a specific type of relation that follows a unique rule: each input in the domain is associated with exactly one output in the range.
To put it simply, all functions are relations, but not all relations are functions. For example, consider the sets of pairs {(1, 2), (2, 3), (3, 4)} and {(1, 2), (1, 3)}. The first set is a function because each input (1, 2, and 3) maps to one and only one output. However, the second set is not a function because the input 1 is associated with two different outputs (2 and 3).
In summary, the critical distinction lies in the uniqueness of output for each input, which is a requirement for functions but not for general relations.