Khaybar was manned by Jewish tribes that had previously reacted treasonously against the Muslims and had been exiled from Medina in turn.
They had already attacked the Muslims once, by participating in the Battle of Khandak, and Prophet Muhammad received intel that those Jewish tribes were again planning to ally with another pagan tribes to attack Medina.
The Prophet again attempted a diplomatic outreach to the tribes in Khaybar, but it fell on deaf ears. Realizing that the Jews at Khaybar were determined to march against Mecca yet again, Prophet Muhammad prepared to strike against them first.
Podcast version: podcast.lifeofprophetmuhammad.com