Where the story is told and why Musa travelled
The story is in Surah al-Kahf, verses 60 to 82. It begins with Musa telling his young servant that he would not stop travelling until he reached the meeting of the two seas, even if it took a long time.
The reason is explained in an authentic hadith narrated by Ubayy ibn Ka'b (may Allah be pleased with him) in Sahih al-Bukhari. Musa was asked among Banu Isra'il who was the most knowledgeable of people, and he answered that he was. Allah reproached him for not returning the knowledge to Allah, and told him that a servant of His at the meeting of the two seas was more knowledgeable than he. In the same narration Ibn Abbas (may Allah be pleased with him) made clear that this is Musa of Banu Isra'il, the messenger of Allah.