Machine learning (ML) allows the Internet of Things (IoT) to gain hidden insights from the treasure trove of sensed data and be truly ubiquitous without explicitly looking for knowledge and data patterns. Without ML, IoT cannot withstand the future requirements of businesses, governments, and individual users. The primary goal of IoT is to perceive what is happening in our surroundings and allow automation of decision-making through intelligent methods, which will mimic the decisions made by humans. In this paper, we classify and discuss the literature on ML-enabled IoT from three perspectives: data, application, and industry. We elaborate with dozens of cutting-edge methods and applications through a review of around 300 published sources on how ML and IoT work together to play a crucial role in making our environments smarter. We also discuss emerging IoT trends, including the Internet of Behavior (IoB), pandemic management, connected autonomous vehicles, edge and fog computing, and lightweight deep learning. Further, we classify challenges to IoT in four classes: technological, individual, business, and society. This paper will help exploit IoT opportunities and challenges to make our societies more prosperous and sustainable.