The great boar of Welsh mythology, which features strongly in the tale of Culhwch and Olwen and is mentioned in the Mirabilia of the Historia Brittonum. The boar has its origins in pagan Celtic religious beliefs, and is probably some kind of pre-Christian animal god, but no one is quite sure, as these were never written down. The Irish similarly have a goddess Brigit, who had a a king of the boars named Triath (which is cognate with Trwyth of course).
The Twrch Trwyth was once a human king, but has been transformed, together with his seven sons (1) into pigs as a punishment for wickedness. The king is not named neither is the precise nature of these sins stated, although I would suggest that the Twrch Trwyth is actually non other than Vortigern. He certainly fits the bill, having (at least traditionally if not historically), committed the sin of marrying his own daughter, and fathering a son by her. (In addition of course, to committing the sin of inviting the Anglo-Saxons into Britain in the first place.)
More importantly, the Historia Britonnum, when it relates the tale of Vortigern and Germanus, makes reference to Vortigern's son giving him a razor, scissors, and comb that symbolise Vortigern's guilt. I think it no coincidence that these are the very treasures located between the ears of the Twrch Trwyth.
The tale of the hunting of the Twrch Trwyth which features in Culhwch and Olwen has a parallel in Greek mythology, when the Greek goddess Artemis sent the Calydonian boar to ravage Greece after Meleager's father Oeneus neglected to carry out the necessary sacrifice to her after the harvest. Meleager organised a large hunting expedition against the beast; and with the aid Atalanta and Amphiaraus is finally able to kill it. After the kill, Meleager opted to award the spoils to Atalanta, whom of course he desired, resulting in an argument in the course of which Meleager killed his uncles.
The tale of the hunting of the Twrch Trwyth is therefore the fusion of a bit of Greek mythology with a Celtic pagan animal deity.
(1) Six of whom (at least), are named as Llawin, Banw, Bennwig, Gwys, Grugyn Gwallt Ereint and Llwydawg Gofynnyad.