The concerned term is hot swapping
External storage (including SD card) should only be removed after it has been unmounted from the system, which ensures that no data gets to be read from or written into the device, so as to prevent data corruption and app crashes. Android supports hot swapping of external storage. However, since there is no way to fully ascertain visibly at what stage of shutdown process the external storage is unmounted, it should be removed only when the phone has powered off.
As for the SIM card, OEMs including Google recommends powering off the device before inserting or removing a SIM card. On the other hand, many Android users since Marshmallow have had success with hot swapping a SIM card just by turning Airplane mode on and off. Some phones explicitly support SIM card hot swapping, such as Samsung Galaxy S7.
Android devices since Android Lollipop comes encrypted, unless they have been exempted (see heading 9.9) owing to major performance degradation from encryption.