The essence of goodness consists in this, that it is in some way desirable. Hence the Philosopher says (Ethic. i): 'Goodness is what all desire' (ST I Q5 A1).When he says this, he doesn't mean that the simple fact that a thing is desired by someone makes it good as such. For example, the fact that a man loves a certain sinful activity doesn't make that activity good as such. But what it means in this case is that he thinks it to be a good (and therefore desirable) thing.
No one wants something that he thinks is evil. We all shun what we think is evil. The problem with respect to sin is that we wrongly think that something wicked is good.
Now it is clear that a thing is desirable only in so far as it is perfect; for all desire their own perfection. But everything is perfect so far as it is actual [for more on this, see here - RdP]. Therefore it is clear that a thing is perfect so far as it exists; for it is existence that makes all things actual...Hence it is clear that goodness and being are the same really. But goodness presents the aspect of desirableness, which being does not present (ibid.).This doesn't mean that the two terms are interchangeable in every sense:
Although goodness and being are the same really, nevertheless since they differ in thought, they are not predicated of a thing absolutely in the same way. Since being properly signifies that something actually is, and actuality properly correlates to potentiality; a thing is, in consequence, said simply to have being, accordingly as it is primarily distinguished from that which is only in potentiality; and this is precisely each thing's substantial being. ... But goodness signifies perfection which is desirable; and consequently of ultimate perfection. Hence that which has ultimate perfection is said to be simply good; but that which has not the ultimate perfection it ought to have (although, in so far as it is at all actual, it has some perfection), is not said to be perfect simply nor good simply, but only relatively. In this way, therefore, viewed in its primal (i.e. substantial) being a thing is said to be simply, and to be good relatively (i.e. in so far as it has being) but viewed in its complete actuality, a thing is said to be relatively, and to be good simply (ibid., ad 1).In this reckoning we see that God's goodness cannot be distinguished from his being. It has to be this way because God is absolutely simple (ST I Q3; for a vagueish attempt at understanding this, see my effort here), so that his goodness is not something added to him or somehow distinct from who he is. God is good because he is God. Hence those who ask whether God might really be evil are not just saying something foolish or wicked, but irrational.
In the same way, there is a measure of goodness in every creature precisely because it exists. God says "all those who hate me love death;" to hate him who is goodness itself is to hate existence itself; consequently, to hate God is the same as to despise one's own life.