学校は創立一年目にして、なんと天文部が存在していたんですよ
in the first year the school was established, (なんと?) the astronomy club existed.
what purpose is it serving here?
According to 明鏡国語辞典:
なんと【何と】
🈔〘感〙強い驚きや感動の気持ちを表すときに発する語。「なんと、できたではないか。」
The なんと in your sentence is a 感動詞(interjection), not a 副詞(adverb). It is uttered to express one's surprise or amazement. This なんと cannot be rephrased as なんて, and can mean "Believe it or not", "To my surprise", "Surprisingly enough", etc.
Examples from Kenkyusha's New Japanese-English Dictionary:
その時部屋に入ってきたのは、なんと私の妻であった。
The woman who then entered the room was -- why! -- my own wife! / Who should then enter the room but my own wife!
借金が積もり積もって、なんと10万円になった。
The debt went on increasing, reaching at last a surprising amount of 100,000 yen.
The following information I found in A Dictionary of Advanced Japanese Grammar by Seiichi Makino and Michio Tstsui (2008). All credit for this answer goes to them if I have understood its contents correctly.
The grammar なんと (and its colloquial version なんて) means: What; How ~! What a(n) ~!; so.
Usage of this grammar is a little advanced, as you may need a little bit of experience with a native speaker of the language to adequately learn the nuances of the structure.
There are three ways to form a sentence using なんと。They are as follows:
Here are a few example sentences using the なんと grammar:
なん{と/て} + Verb
うちにホームステイしている留学生がテレビを観ていると「今なんと言った?」「英語だとなんと言いますか?」と質問の連続だ。
When the foreign student staying with us watches TV, he keeps asking questions like "What did he say?" or "What is that in English?"
なん{と/て}+ いう + Noun
なんという人か名前を忘れたけれど、なかなか魅力的な女性に出会った。(I met a very charming lady, although I've forgotten her name.)
なんて + {Adj(i) infinitive /Adj(na) inf./Noun な}んだろう。
なんと親切なんだろう。(How Kind he/she is!)
なん{と/て}ひどい話なんだ!(What a horrible story!)
The Result?
So if I were to take a whack at translating your sentence above, I would translate it as something like this:
Considering that the school is in its first year since foundation, what an astronomy department they have!
The bold part represents what なんと would be translated into in English.
そこで会ったのが何と田中さんでした Who should I meet there but Mr. Tanaka!
(dictionary.goo.ne.jp/je/56891/meaning/m0u/…)なんとガムのおまけだったんだよ。 Believe it or not, it came in pack of gum.
(ejje.weblio.jp/sentence/content/…)