It is quite possible that the techs necessary to come up with a solution to deal with the threat could end up having substantial spinoff applications, thus paying for itself quite comfortably.
Otherwise the society in question would have to be, among other things, a post-scarcity one where capitalism has been transcended and money no longer exists.
Just adding a mostly off-topic note. Virtually certain that the 3 masted schooner in the over the horizon photo is the Victory Chimes, which I saw regularly at sea when I was on another boat off the Maine coast 2 decades ago.
Idly curious if she was still sailing, just found out that she sunk at her moorings in NY Harbor a week before this LW entry was posted.