When writing on a page, priests needed to save space and a double “NN” takes a huge unnecessary space in the line. They found out a solution of adding a tiny “n” on top of the main “N” character. This evolved into the little swirl on top of the “ñ”, et voilà.