puts emphasis on just how much something is.
Note that it comes from {殊|こと} not 事, so it should not be confused with こと
It's mostly in #written-language , as it sounds a little dramatic. Can also be used in speech to mock that though.
あの人のコンサートには何回行ったことか。 God knows how many times I have gone to that person's concert.
うちの犬はどんなに可愛いことか。 Can i explain just how cute my dog is?
どれだけお前の事を愛していたことか!それでも俺はお前に裏切られた! Just how much I loved you! Yet, you betrayed me.