Background: The Internet of Things (IoT) has improved many aspects that have impacted the industry and the people’s daily lives. To begin with, the IoT allows communication to be made across a wide range of devices, from household appliances to industrial machinery. This connectivity allows for a better integration of the pervasive computing, making devices “smart” and capable of interacting with each other and with the corresponding users in a sublime way. However, the widespread adoption of IoT devices has introduced some security challenges, because these devices usually run in environments that have limited resources. As IoT technology becomes more integrated into critical infrastructure and daily life, the need for stronger security measures will increase. These devices are exposed to a variety of cyber-attacks. This literature review synthesizes the current research of artificial intelligence (AI) technologies to improve IoT security. This review addresses key research questions, including: (1) What are the primary challenges and threats that IoT devices face?; (2) How can AI be used to improve IoT security?; (3) What AI techniques are currently being used for this purpose?; and (4) How does applying AI to IoT security differ from traditional methods? Methods: We included a total of 33 peer-reviewed studies published between 2020 and 2024, specifically in journal and conference papers written in English. Studies irrelevant to the use of AI for IoT security, duplicate studies, and articles without full-text access were excluded. The literature search was conducted using scientific databases, including MDPI, ScienceDirect, IEEE Xplore, and SpringerLink. Results were synthesized through a narrative synthesis approach, with the help of the Parsifal tool to organize and visualize key themes and trends. Results: We focus on the use of machine learning, deep learning, and federated learning, which are used for anomaly detection to identify and mitigate the security threats inherent to these devices. AI-driven technologies offer promising solutions for attack detection and predictive analysis, reducing the need for human intervention more significantly. This review acknowledges limitations such as the rapidly evolving nature of IoT technologies, the early-stage development or proprietary nature of many AI techniques, the variable performance of AI models in real-world applications, and potential biases in the search and selection of articles. The risk of bias in this systematic review is moderate. While the study selection and data collection processes are robust, the reliance on narrative synthesis and the limited exploration of potential biases in the selection process introduce some risk. Transparency in funding and conflict of interest reporting reduces bias in those areas. Discussion: The effectiveness of these AI-based approaches can vary depending on the performance of the model and the computational efficiency. In this article, we provide a comprehensive overview of existing AI models applied to IoT security, including machine learning (ML), deep learning (DL), and hybrid approaches. We also examine their role in enhancing the detection accuracy. Despite all the advances, challenges still remain in terms of data privacy and the scalability of AI solutions in IoT security. Conclusion: This review provides a comprehensive overview of ML applications to enhance IoT security. We also discuss and outline future directions, emphasizing the need for collaboration between interested parties and ongoing innovation to address the evolving threat landscape in IoT security.