Illumination change, image blur, and fast motion dramatically decrease the performance of visual-inertial navigation systems (VINS). This paper presents a new illumination-robust visual-inertial odometry (IR-VIO) based on adaptive weighting algorithm with two-layer confidence maximization. First, to prevent the VIO performance degradation caused by poor image quality in complex scenes and ignoring the confidence differences of feature points, we develop a novel adaptive weighting algorithm on the multi-sensor layer and visual feature layer to better fuse multi-sensor information and maximize the overall confidence of VIO. Second, to solve the problems of image feature tracking difficulty and excessive image noise in illumination-changing scenes, an image enhancement algorithm is introduced to enhance consecutive images to the same brightness level, while a block noise removal algorithm with constraint protection mechanism is proposed to dynamically remove feature points in noise areas. Finally, experimental results on the public dataset and real-world environments demonstrate that IR-VIO has superior performance in terms of accuracy and robustness compared with the state-of-the-art methods. Supplementary video is available at https://youtu.be/163Sk7twEMY.