1. They are building artifical islands so they can better control the south china sea, which is the gateway for 90% of their foreign trade and linchpin of their economy.
2. They've been blustering about Taiwan for 70 years and have never done anything.
3. China basically hasn't conducted offensive military campaigns for hundreds of years, they are huge but insular and have always valued holding their country together over expansionism.
4. One exception to 3) was the invasion of Vietnam in the 70s. It wasn't expansionism per se, more an attempt to bring Vietnam to heel and China got their ass kicked.
5. Its extremely unlikely China can brute force an invasion of Taiwan. Russia could conduct a surprise invasion of Ukraine by just by driving tanks and trucks up anywhere on a thousand mile border, China has to sail troops for 10 hours over ocean while being easily monitored and subject to missile barrages for hours before they can even see shore and start taking direct fire from artillery, machine guns and Javelins.
6. Anyone who doesn't understand how many times harder amphibious operations are should just ask Hitler why he never authorized Operation Sea Lion to cross the relatively tiny English Channel and invade Britain. Or to look up the casualty counts we took in Okinawa despite total air and sea superiority and the months it took to clear out the resistance in an island a tenth the size of Taiwan.
7. As you described, even if China wins Xi is not going to gain economically. China will be subject to robust sanctions for years, maybe decades, and all the TSMC engineers will flee to the west so that even if the plants aren't demoed into rubble China won't have the skills to keep them operating.
8. Xi knows all of these things. More importantly for him are #1 and #3, because even if he could easily overwhelm Taiwan the South China Sea won't be re-opening for trade for a very long time, plunging China into a depression with mass unemployment and young people marching in the streets and Tiananmen Square, and risking his control of the country.