It's a little bit outlandish, but the most plausible theory I've heard is the Saudis were happy to spend the cash[1] to try to hinder future Arab Spring style events, which were organized largely on Twitter. US banks have a similar motive, it's not hard to draw the line that they would see disrupting low-level leftist activist communication networks on Twitter as valuable. Under that theory, Musk isn't so much doing a favor as being a useful idiot.
The Saudis were already the top shareholder in Twitter before Elon’s purchase. They were adamantly against it until he let them roll over their stake into X
[1] https://www.aljazeera.com/economy/2022/10/28/how-elon-musk-f...