Thomas Aquinas said this quote

What causes love, since it is a passion, is its object; and since it is a sort of affinity or agreement with the object, what causes love is the goodness or agreeableness of that object. Evil can only be loved because it seems good, because being partially good it is perceived as wholly so. And the beautiful is a form of the good: if something is agreeable in general we call it good, and if the perception of it is agreeable we call it beautiful. But goodness must be known before it can become the object of love, so knowledge itself can be said to cause love. Knowing is an activity of reason, which abstracts from things and then makes connections between them, needing to know each part and property and power of things if it is to know them perfectly. But loving is an appetite for things as they stand, and to love perfectly we need only love them as they are perceived to exist in themselves.