Why do commercial banks buy government bonds at negative interest rates instead of keeping cash? I know commercial banks need to meet liquidity requirements, but why would they choose to invest their money in an instrument that is guaranteed to give them a negative return, instead of just keeping their clients' money in "cash"?

Is there some legislation forcing them to use government bonds?
For a bank , the basic choice of assets is between (a) loans to customers (b) invest in financial asset such as government bond (c) deposits with the central bank.  Note that (c) may return a negative interest rate, so (b) may be better than (c).  Holding a large amount of physical cash in the vault is not practical for a bank of any decent size, due to the cost of storage and insurance.  It would also be discouraged by the bank regulators , because it would frustrate the negative interest rate policy the central bank is trying to apply.