We recently had an issue where all the data for certain entities got deleted, which is only possible if that entity has been deleted, which could have been triggered by the deletion of the managed solution.
As it was on-premise, we started our analysis with the wonderful Solution History plugin of XrmToolBox.
The Solution History had the information of new managed solution being imported.
But it didn’t capture the delete event for the solution or the entities.
The good thing was that we had the audit enabled, which helped us to figure out the entities deleted and account that was responsible for this delete (accidental).
For online, it is straightforward to track the solution import and delete event, now with the Solution History available in the product itself.
Another thing to remember with regards to the deletion of the managed solution is,
If Solution A has entity A and entity B and this has been imported as managed in Production first, followed by Solution B that has entity A only.
If Solution B is deleted only Entity A will be deleted as entity B is still being referenced by Solution A.
Check the below blog post to understand the installation order and solution layering.
Hope it helps..