https://stats.stackexchange.com/a/276376/61705
"The idea of utility is very simple. It converts the numerical outcome into the utility to you. Say, you get 10 apples or 5 oranges, or some combination of two. How would you compare apples to oranges? Easy, I offer you to take either of two choices, and you pick one. So, theory goes that there's some kind of a function
such that when you feed it a basket of goods with quantities of each good, this function returns a scalar value, which reflects the utility of this basket to you. You pick the one with a greater utility.
So, if I feed it or , where the good 1 is apples, and the good 2 is oranges, it'll return two different numbers, the greater one will indicate which basket has more utility to you. YOu can combine goods in the same basket - one apple and one orange.
So, in a nutshell, the utility function is a concept that allows us to compare apples to oranges. The theory states that you pcik the baskets based on their utility, which is calculated by plugging the basket descriptions into this utility function."