Casual, emphatic exclamation of shock, dismay, or frustration. A contraction of なんてことだ. Often used by male speakers.
Oh no! I forgot my wallet.
Damn, rain again?
くそ is a blunt, vulgar curse used on its own, while 何てこった is a fuller exclamatory phrase expressing disbelief.
Contraction of なんてことだ (nante koto da), literally 'what a thing it is'.