To safely handle a pet tarantula for cleaning its habitat, you should wear gloves to protect yourself and gently coax the tarantula into a temporary container using a soft brush or a cup. Once the tarantula is safely in the container, you can remove it from the habitat and proceed with cleaning. Be sure to handle the tarantula with care and avoid sudden movements to prevent stressing or harming the spider. After cleaning the habitat, return the tarantula carefully back to its enclosure and allow it some time to settle back in.