The optimal carrier concentration of thermoelectric materials increases with increasing temperature. However, conventional aliovalent doping usually provides an approximately constant carrier concentration over the whole temperature range, which can only match the optimal carrier concentration in a narrow temperature range. In this work, n-type indium and aluminum codoped PbTe were prepared with high-pressure synthesis, followed by spark plasma sintering. While Al doping can provide a roughly constant carrier concentration with varying temperatures, In doping can trap electrons at low temperatures and release them at high temperatures, thus optimizing the carrier concentration over a broad temperature range. As a result, both electrical transport properties and thermal conductivity are optimized, and a significantly enhanced thermoelectric performance is achieved in InxAl0.02Pb0.98Te. The optimal In0.008Al0.02Pb0.98Te shows a peak ZT of 1.3 and an average ZT of 1, with a decent conversion efficiency of 14%. Current work demonstrates that optimizing carrier concentration with varying temperatures is effective to enhance the thermoelectric performance of n-type PbTe.