We want to measure the quality of a solution, that is given two solutions, $x, y \in A$, I want to tell if $x$ is a better solution than $y$.
Real numbered as an ordered field enable us to compare two solutions conveniently.
For example, for a minimization problem, we can say that $x$ is a better solution than $y$ if $f(x) < f(y)$.
It can carry meaning of operation cost or approximation error, something that you want to minimize.
However, in general, of course, it is possible that you might want to measure something based on different quantity and obtained a tuple instead. You can define own notion of comparison, $<$. For example, we might want to define things to be compared lexicographically. It is possible but for the scope of the text/paper that you read, they might want to study a particular class of problem.