The idea of using the Kirpan (sword) is that Shastar (weapon) is a form of Guru. Guru Gobind Singh Ji has written in their Bani that the weapons are my Guru. By swiping the Kirpan in the food first, our Guru is consuming that food and it is making that food Pavittar (purify/blessed).
It is similar to the concept of Charan Amrit when Guru Ji dipped/touched the water with their feet and Sikhs would drink it.