I understand that the Trojan War is possibly historical, but that's just an example given due to the presence of Odysseus in the Inferno.
Oh yes.
Now, regardless of what's believed today, the Trojan War was definitely regarded as a historical event during the Middle Ages, and it was quite a hot topic from the 12th century forward, (so, in Dante's time). One example of several popular history books of the time that includes Troy is the Historia Scholastica written in 1178 by Peter the Eater (commonly known as Petrus Comestor, or Pierre le Mangeur, but it obviously sounds more fun in English!). The Historia Scholastica was was a very popular and influential textbook of the era and would remain so for the following century. But also literary accounts of the Trojan War became popular in that era, such as the very popular French Romane de Troie (1160) by BenoƮt de Sainte-Maure and De Bello Troiano (1183) by the Joseph of Exeter. It was a whole genre referred to as the "Matter of Troy". Even the 13th century Icelanders wrote a Saga of the Trojans about it. Perhaps most relevant here is the reworking of Sainte-Maure's epic poem by a a Sicilian contemporary of Dante, Guido delle Colonne, as Historia destructionis Troiae (1286). Guido is also influenced by Peter the Eater's Historia. Since Dante mentions Guido in his writings so it's not at all unlikely he might've been influenced by the latter that in his knowledge of the Trojan War. It was certainly not from Homer's texts - these had been lost to the West and were not rediscovered until a few decades after Dante's death. What they did have were secondary accounts such as Dares Phrygius and not least the Aeneid of Virgil; which, as is obvious from the Divine Comedy, Dante held Virgil in high esteem.
However that does not mean the pagan elements were gone. The question then for the devout medieval scholar was how to interpret this obvious error. The answer is euhemerism; the explanation of myths by casting the gods of old as historical figures, powerful ones that'd perhaps been viewed as god-like, to the extent that people erroneously started believing they were gods. This explains the history and it has the added bonus of denying their godhood with no extra effort. Euhermerisms were a common thing in the Middle Ages, although they can be traced back even earlier. The aforementioned Peter the Eater was one of those historians who engaged in this, and the Trojan War. Another example better known to me as a Scandinavian is the account of Snorri Sturluson, who recorded most of what's known of Norse mythology, and wrote a prologue showing how Thor, Odin and friends were all decedents of king Priam of Troy, and in turn of Saturn and the other 'real' Roman gods and even Zoroaster. Although the latter part was not original but goes back at least to Isidore of Seville (6th century).
So there was a long history of euhemerism and it's likely through it that we have much of these stories still around today. For if they were merely fantastical stories without historic content, or worse - some sort of pagan scripture - then medieval scribes would've seen little value of preserving them.
As for Ulysses himself, the Divine Comedy is fairly explicit in why he's being punished; for the deceitful horse trick and theft of the Palladium. Now bear in mind here what I mentioned earlier; Dante's Ulysses is not the Ulysses of the Illiad but the Ulysses as Virgil depicted him in the Aeneid, who's a less heroic and more duplicitous character. I'm not comfortable getting too deep into that, though, since there are Classicists and Literary Studies folks who've forgotten more about that kind of stuff than I've ever known.
Additional Source/more reading on euhemerisms:
John Daniel Cooke, Euhemerism: A Mediaeval Interpretation of Classical Paganism, Speculum, v2, No 4, 1927, p396-410