We're talking about middle ages 12.century and He was capable of speaking many languages but how...
Frederick II grew up in Palermo, a city that at that time was still fairly multicultural, and was a significant center of commerce and culture. When the Normans conquered Sicily and the south of the Italian peninsula in the late 11th century, there was still a sizable Byzantine Greek community in Apulia, Sicily and the rest of the south. Normans put their bureaucracy in the hands of a mix of Arabs and French Normans, and that was essentially still the case when Frederick arrived in Palermo, the capital of the Kingdom of Sicily, as an infant. So while the young Frederick was growing up, certainly Norman French, Arabic, Greek were spoken in the city and in the royal palaces. The sources paint the picture of a bright, inquisitive child who grew up with an interest in Arabic and Greek culture, someone motivated to become literate in those languages in order to read the texts that were available in Palermo around the end of the 12th century. That is how he ended up knowing at least some of all those languages.