The ability to see color conferred a selective advantage in evolution, allowing animals to see possible food from further away.
A byproduct of that is our ability to see sunsets. But does the ability to see a sunset convey a selective advantage?
Well, yes. It allows us to realize that there is something more worthwhile to life than simply eating. There is the sense of contentment.
Contentment gives us time to notice sunsets, and all that is beautiful or sublime.