What is the work that the computer performs while it does Bitcoin mining? Is it useful work in any case?
It's not useful in any way other than maintaining mining in the bitcoin protocol. This is wasteful, but it is the easiest solution to the problem it's solving, you can quickly verify the correct sha256 hash. If an imaginary coin did computations for charity as it's "mining", how could people verify a node claiming to have done 100 computations correctly without also doing the same work?
Mining is useful in that it solves the double spending problem, provides the confirmation of transactions and security of the network. It also doubles as the mechanism to spread the currency without having a central dispensary, creates a positive reward for people to drive adoption, and makes it more attractive to spend computing power to benefit the network than to attack it.
All you are doing is computing sha256 hashs. You can read more about it here https://en.bitcoin.it/wiki/Mining. What do you mean by useful that is pretty ambiguous.