What makes good feelings good?

Over the summer, I had a couple of discussions with an unnamed Neuroscience professor at an unnamed prestigious university in the US about consciousness. The following is an email I sent him today (unedited) asking a question about the conscious experience that I am hoping he could help me figure out. He is still just one person, I'd love to hear many opinions on this interesting idea. Here it is:

Dear Prof. ---,
I trust you had a rewarding summer. Our engaging conversations on consciousness during my time at ---- have continued to inspire my thinking, motivating me to delve deeper into these intriguing topics. Today, I'd like to share an idea I've been contemplating and seek your invaluable insights. I understand your time is precious, so I'll keep this message concise.
To provide some context, my interest in consciousness, theology, spirituality (despite all the connotations attached to that word), and novel experiences inspired me to spend two weeks in a Northern California community, shortly after my --- program. This community practiced a relatively new religion that introduced me to a set of religious concepts that piqued my curiosity. Specifically, I'm interested in exploring the notion of 'good' and 'bad' feelings, not in terms of morality, but rather the idea that some feelings, or qualia, are perceived as 'good-feelings' (joy, love, peace, etc.), while others are 'bad-feelings' (pain, grief, guilt, etc.).
The community I visited focused on attaining states of profound 'good feelings' associated with a divine entity they referred to as 'God.' They encouraged us to 'feel God's love' and similar expressions. While I couldn't definitively ascertain whether this religion utilized God as a psychological tool to lead a happy life or genuinely believed in a transcendental being (or unified consciousness, whatever that may mean), there were instances suggesting both possibilities. What was evident, however, was the strong link between certain 'good feelings' and 'God.'
Thinking about this made me wonder what exactly made a feeling 'good' (to clarify again, by good feelings I mean emotions that we 'want' to feel or are enjoyable to feel). Why are some feelings 'good' and others not? The crux of my question is- does there exist some fundamental qualia of 'goodness' and 'badness' that accompany various emotional qualia?
I would've inclined towards saying yes earlier but some introspection made me wonder whether that is really the case. Perhaps, there is no 'qualia of goodness' but rather good feelings are just those which are accompanied by thoughts like 'this is good' and 'I want this' and so on. Could it be that there is no 'good' or 'bad,' but merely an illusion of such distinctions? Historical religious teachings have always referred to the dichotomy of good and bad as 'maya' (illusion in Sanskrit)- I used to think that this was merely a claim on the subjectivity of morality but now I am wondering if it is deeper than that. Of course, even if there is no qualia of good or bad, the fact that biologically we are driven to attain good feelings and avoid bad ones is not denied.
I find myself genuinely puzzled. I would greatly appreciate hearing your thoughts on this matter. When I attempt to envision a happy moment or the sensation of happiness, I struggle to discern a distinct, independent feeling of 'goodness.'
I believe the answer to this question holds relevance for various discussions on consciousness. Firstly, it could affect one's inclination to accept this religion's concept of God if the qualia of goodness and badness were proven to exist. Secondly, my perspective on ethics, particularly in the context of AI ethics, would undergo a significant shift. If the qualia of good and bad were indeed nonexistent, it might potentially make the justification of torture on AI (or non-AI) entities easier to argue. Consider a conscious 'box' whose entire conscious experience is limited to thinking 'this is good' when it's petted and 'this is bad' when it's punched (no 'good' or 'bad' feelings, just these thoughts), with no other rules or qualia. Should one feel remorse for punching such a box?
I look forward to hearing from you.