Why does Albany cede the kingdom to Edgar and Kent at the end of King Lear? Shouldn't he, by rights, be king?
You are right, of course. By rights, Albany would have the strongest claim to the crown by the end of the play. However, let us briefly consider the Duke of Albany and his role in the play. He is shown to be basically a good man. However, he allows himself to be dominated and manipulated by his evil wife, Goneril. Even when he becomes aware of his wife's more sinister actions and motivations in the second half of the play, he still does very little to actually stop her. As a result, he is showing the way in which even good characters in this play are shown to be rather weak and ineffectual.
Perhaps, then, his ceding of the kingdom in the final lines of the play to Edgar and Kent is an indication of his own inability to be the kind of ruler that Britain needs at this particular point. Note how he actually phrases this bestowing of power:
Albany perhaps is able to see with clarity that Britain, in its current "gored" condition, needs a strong ruler that can give it direction, strength, and stability. He has been able to reflect on the fact that the way his wife dominated him indicates that he is not that kind of ruler. His goodness is therefore shown through the way that he puts the needs of the nation over his own personal ambition and chooses two characters who he thinks will do a better job than he will.
I think part of it is that he did fight against Lear, and through his connection with Goneril, is somewhat guilty of treason. He also may not trust himself with power. At that point, I guess he would legally be king, but the whole court system is in a bit of confusion.
Also, it could be a dramatic element that Shakespeare added, to make his audience happy. It may have been more satisfactory to end with the restoration of power to characters who have been portrayed as "good" throughout the play, compared to a character that has just "become good" or that the audience has realized is actually a decent guy.
He is also dealing with the death of his wife, although he did not seem to like her all that much.