That’s a deliberate policy decision agreed by HMT and regularly reviewed (last in 2023), not a cash grab by the family. It only applies to the Sovereign and consort too - all other family members, and bequests to other family members, incur tax in the normal way.
The reasons for the exemption, as set out in 2023:
Some assets are held by The King as Sovereign rather than as a private individual. They are not sold to provide income or capital for the personal use of The King and pass from one Sovereign to the next. The official residences, the Royal Archives, the Royal Collection of paintings and other works of art and other assets held by The King in right of the Crown fall into this category. It would clearly be inappropriate for inheritance tax to
be paid in respect of such assets.
In relation to assets which can properly be regarded as private, the arrangements provide that inheritance tax will not be paid on gifts or bequests from one Sovereign to the next, but will be payable on gifts and bequests to anyone else. Tax will also not
be payable on assets passing to the Sovereign on the death of a consort of a former Sovereign. The reasons for not taxing assets passing to the next Sovereign are that private assets such as Sandringham and Balmoral have official as well as private use,
and that the Monarchy as an institution needs sufficient private resources to enable it to continue to perform its traditional role in
national life, and to have a degree of financial independence from the government.
Obviously you are free to disagree with the policy reasons expressed here, but some thought has gone into what is appropriate here over a number of decades by successive elected governments.