Forecasting air quality index (AQI) is critically important to provide a basis for government policy makers, especially in public health, smart transportation, energy management, economic development, and sustainable environments. In reality, AQI consists of various components, such as PM2.5, PM10, CO, NO2, and SO2. Although numerous methods have been presented, few studies concurrently considered the causalities of socioeconomic indicators and meteorological factors and different data granularities. The aggregate AQI of Taiwan comprises five representative cities: Taipei, Hsinchu, Taichung, Tainan, and Kaohsiung. Research findings identify seasonal factors, carbon power generation, steel and metal production, highway cargo load, the number of registered cars, and retail and manufacturing employment population as the key indicators to predict the monthly AQI of Taiwan. For the daily AQI of Hsinchu and the hourly AQI of Kaohsiung, PM2.5, PM10, O3, ambient temperature, humidity, wind speed, wind direction, and pollutants (CO, NO2, and SO2) are recognized. Deep learning significantly outperforms machine learning in the hourly AQI while it performs slightly better in the daily AQI. With the presented framework, governments can balance the trade‐offs between economic development and environmental sustainability.