Generally, you have 3 types of endings in any form of media. The first is the good ending. This is where everything works out fine. The second is the bad ending where you did something wrong resulting in a nonstandard game over. The last is a bittersweet ending where you win, but you had to pay a heavy price to achieve it. Sometimes, it might also overlap with a tragic ending which is almost the same except that the ending is just an outright depressing. On rare occasions, there are special hidden endings in games with multiple endings that break away from these paths often requiring extra work in order to select all the right options to achieve the true ending of the game.
The problem with good endings is best exemplified with "Victory is boring". This means that you are basically the invincible hero and everything always works out fine. More often than not, this results in a reset button where the main villain is stopped and everything is fixed. The problem is that nothing is different at all. You might have gone through a several year long journey, but there is nothing to show for it. Character development falls flat and no one really changed from their experience. The villain's motive was just a simple to conquer the world or destroy it rather than have some sort of depth to his character.
The problem with bad endings is that you failed and the bad guys win. It has the same problem as good endings. It is very one sided and the bad guy just destroys everything. His goal was a simple take over the world and they accomplished it. Once again, character development falls flat and neither side shows any depth. It is just very one sided. There are few exceptions such as the bad ending in Breath of Fire 4 where you are forced to turn on your party if you make certain decisions. However, if you take into account the other half's ending, you realize that it is a much more tragic one than a bad ending.
The reason why I like bittersweet endings is that they give a sense of change along with a sense of conclusion. Character development is more complex and heroes and villains both show some form of character development. You either find out about the villain's motivations being far more complicated than king big nuts of the world and the heroes are more than just teenagers with attitude out to stop the guy because adults are useless. While things do sort of go back to normal, at the same time, something has changed about the characters that make them see the world in a different way or the world begins to do things differently. The journey has a lasting impact on everyone that they met and affected them for at least a little while.
There are several examples of what a bittersweet ending might include.
1) Character Change
The first and most important thing is that characters change. What kind of person they are at the beginning should be different from what kind of person they are at the end. They should have learned something other than not to be impulsive. The whole point of the journey is to learn that lesson that changes you to see things a certain way. It might not always be obvious such as the need to trust someone else (the power of friendship) or might just be a simple "i need power" (weapons). The most common is that the journey forcibly lands them the role of leader and learning the qualities of a good leader is what changes them.
2) Victory At A Price
One of the ways to have an emotional impact on the characters and the player is to kill off someone for real. The closer that person is to the player and the party, the more emotional the impact. However, the most important thing is the timing. More often than not, if you see someone suddenly gets lots of character development from nowhere, you can be sure that they are going to be killed. Development needs to happen over time in order to increase the attachment to them. Having one off info dumps really does not help much with character development. This is one of the reasons why Final Fantasy X had a more significant impact. Tidus was with the main party the whole game only to disappear at the end and deny both him and Yuna a happy ending. The death of an unknown or relatively minor character has much less of an impact.
3) The Official Couple
There is almost always a male lead and a female lead in any game. You can be guaranteed that the female lead will almost always be the love interest. The question is what you do with this. Most of the time, it is just one of them fawning over the other and building lots of will they or won't they sort of romantic tension. While this works in the short run, the more you drag it out, the more unlikely they are going to hook up and the less you care about their relationship. There needs to be more than a simple will they or won't they. Sometimes the death of a loved one is exactly what is needed to push them into the relationship. At other times, the desire to prevent the death of a loved one is what keeps them apart because the villain has targeted the hero and unless the girl forces herself into the group, she would be someone who is incapable of defending themselves against the villain's power.
4) What Have We Done
This is often one that is overlooked because there is usually a right and a wrong. The problem is when a game decides to enter the grey and grey morality zone. The traditional one is black and white where one side is good and one side is evil. The grey and grey model assumes that either side can be right and either side can be wrong. Both sides have valid reasons for what they are doing. Their reasons for going against each other might be simply political. In something like a war, the defeat of the commander (and assumed primarily villain) could potentially doom an entire empire to your side's post-war brutality. In the worst possible scenario, your actions might doom many people. The best example of this is Derris Kharlan in the Tales of Phantasia/Symphonia world. Half-elves are hated by everyone and they have no place in society. Dhaos spends the entire game trying to get a Mana Seed from the tree Yggdrasil in order to give Derris Kharlan a fighting chance. His enemies were mostly carefully selected though he did use violent means to get what he wants. The problem? Defeating him dooms the future of half-elves to forever second class citizenship in the entire world. Oops.