*spoilers for anyone who hasn't read the last book*
Hi! So if you are referring to the very very end of the book, Frodo was given permission to go to the Undying Lands/Valinor along with Bilbo. They got to go because they were such vital members of the whole goal of destroying the Ring and Sauron as well as the fact that they had both been damaged by the effects of the ring and living in Arda for the rest of their days was not going to be pleasant.
Hope this helped! :)