You confused revenue and profit. You must subtract expenses to calculate the profit. For example, if you buy something for $20 and sell it for $21, your revenue is $21, but your profit is only $1.
Facebook reported a profit of $39 billion in 2021 and $23 billion in 2022. This takes their expenses (salaries, offices, data centres, etc.) into account.
Microsoft does collect a lot of data. But storing every keystroke is first of all impractical, because it would take a lot of disk space to store every keystroke of every user, and secondly not very useful unless they also knew when, in which application, and in what context each key was pressed.
You confused revenue and profit. You must subtract expenses to calculate the profit. For example, if you buy something for $20 and sell it for $21, your revenue is $21, but your profit is only $1.
Facebook reported a profit of $39 billion in 2021 and $23 billion in 2022. This takes their expenses (salaries, offices, data centres, etc.) into account.