Internet of Things (IoT)-assisted skin cancer recognition integrates several connected devices and sensors for supporting the primary analysis and monitoring of skin conditions. A preliminary analysis of skin cancer images is extremely difficult because of factors such as distinct sizes and shapes of lesions, differences in color illumination, and light reflections on the skin surface. In recent times, IoT-based skin cancer recognition utilizing deep learning (DL) has been used for enhancing the early analysis and monitoring of skin cancer. This article presents an optimal deep learning-based skin cancer detection and classification (ODL-SCDC) methodology in the IoT environment. The goal of the ODL-SCDC technique is to exploit metaheuristic-based hyperparameter selection approaches with a DL model for skin cancer classification. The ODL-SCDC methodology involves an arithmetic optimization algorithm (AOA) with the EfficientNet model for feature extraction. For skin cancer detection, a stacked denoising autoencoder (SDAE) classification model has been used. Lastly, the dragonfly algorithm (DFA) is utilized for the optimal hyperparameter selection of the SDAE algorithm. The simulation validation of the ODL-SCDC methodology has been tested on a benchmark ISIC skin lesion database. The extensive outcomes reported a better solution of the ODL-SCDC methodology compared with other models, with a maximum sensitivity of 97.74%, specificity of 99.71%, and accuracy of 99.55%. The proposed model can assist medical professionals, specifically dermatologists and potentially other healthcare practitioners, in the skin cancer diagnosis process.