Basically, they are going to the
Valinor via the Grey Havens (Grey Havens is the port where the boat left) which is all the elves have gone when they left middle earth. It is mentioned briefly in (I think) the second movie when Arwen was on horseback about to leave middle earth with the rest of the elves and she sees her vision of her future son. It is also mentioned/allueded to, I think, briefly in the first movie when Frodo first leaves the Shire and camps in the woods and they see the elves (extended edition only!). Often referred to as the undying lands because only those the immortal's could reach it (with the exception of the bearers of the OneRing)
The elves (and Gandolf as the last wizard) are leaving middle earth because the time of magic and the elves has passed.. and it is moving into a new age (the age of men).
Most of the first two ages (the Lord of the Rings takes place during the third age of Middle Earth) aren't documented in the lord of the Rings books but in the Silmarillion. The
First Age basically is the beginning of time on Middle Earth and is the emergence of Elves. The
second age ends with the first fall of Sauron.
The Lord of the Rings books does go a little more into it but not into great detail about what it all is and what it all really means. The Silmarillion and the History of Middle-Earth series of books gets into more of the canon and world that makes up Middle Earth.