Thou wast not born for death, immortal Bird! No hungry generations tread thee down;
He thinks that the nightingale must be immortal: it can't die. (Someone needs to buy him a book on biology.)
Being immortal, the nightingale is not followed by future generations, which are metaphorically "hungry" in that they take the place of their parents. This is a very pessimistic view of the cycle of life. Basically, the younger folks are hunting down their own parents to run them off the planet.
The voice I hear this passing night was heard In ancient days by emperor and clown:
Oh, OK, so he doesn't necessarily mean that each nightingale is immortal. He means that the nightingale's voice is immortal, because all nightingales produce the same beautiful, haunting sound.
His talk of generations leads him to think of human history.
Emperors and clowns in the old days listened to the same voice of the nightingale that he hears now How old? The reference to emperors makes us think of Ancient Rome. Keats was an Italian buff.
Perhaps the self-same song that found a path Through the sad heart of Ruth, when, sick for home, She stood in tears amid the alien corn;
The speaker moves slightly further back through history, from Imperial Rome (we think) to the Old Testament of the Bible (also known as the Hebrew Bible).
The Book of Ruth is one of the lesser-known books in the Hebrew Bible. The story goes that Ruth married a guy and moved to a new country. Then her husband died, and Ruth's mother-in-law told her to return home and get married again. But Ruth was like, "I'm totally loyal to you and can't leave you." She supports her mother-in-law by working in the fields of this (to her) completely strange and random place. Eventually she finds a new husband. The end.
Keats imagines that Ruth heard the nightingale's song while she was working in the fields in this foreign or "alien" place, and it caused her to start weeping. We wish we had more info on why exactly he chose this story: it's a curious reference!
The same that oft-times hath Charm'd magic casements, opening on the foam Of perilous seas, in faery lands forlorn.
He notes another time that the nightingale's song might have been heard. But now he has left regular human history all together in favor of fantasy.
A "casement" is either a normal case or a window that opens on a hinge. The speaker thinks the nightingale's song has "charmed" a casement on a ship, and the casement opens. Somehow "magic" is involved, but we think Keats is just using words that conjure up the images of fantasy.
The nightingale flies out the window and over the open ocean. There is an air of danger: this is no regular ocean. It is the ocean surrounding a fantasy world or "faery land."
Keats might be thinking of the stories of knights, fairies, and monsters from Edmund Spenser's famous Renaissance poem, The Faerie Queene.
After it flies out the window, the nightingale is alone and abandoned – "forlorn" – in this strange land.