The LHC cost was 2% of the yearly revenue of Apple I am fairly certain that we can "afford" it.
Musk wasn't donating $42B to Twitter. He raised capital to purchase Twitter with the aim of actually making a return on that money.
A better example is someone like Warren Buffet donating ~$50B dollars to charity instead of building another particle collider. If only Buffet was more interested in the universe's structure eh.
[1] https://www.forbes.com/sites/mattdurot/2022/06/14/warren-buf...