I don’t think anyone knows the answer to this question. I guess that emotions must have evolved because they help us to survive. Early humans probably depended a lot of living in groups and working together to survive so having emotions and being able to recognise emotions in each other might have helped the group work together better to look after each other.
People aren’t the only things that have feelings – but we’re not sure how much it crosses over with consciousness or self awareness.
It’s not obvious why we have a lot of emotions, but they are probably something to do with a survival response. So love might be an extension of the need to mate, or to look after your children to make sure they survive to carry on your genes…
Things like guilt, or sadness are more difficult to explain, and might be more of a side effect of being self aware.
I wonder if alien species would have feelings, or if they would just have instincts like most animals on Earth…
We think that most of the reason that we have ‘feelings’ (emotions) is that we are social animals and it partly helps us live together with other people.
Imagine if you couldn’t tell if people were sad or happy or angry: those feelings help us, by ourselves, to understand we have a problem or reward us if something good happens, or let us do things a bit more quickly when we are angry. Without being sad or happy or angry, other people wouldn’t easily be able to tell if we were in danger, or doing okay, or in need of friendship.
So the need to live together isn’t the whole answer of why we have feelings, but perhaps it is part of it.