The influence of strain relaxation on the optical properties of AlGaN quantum wells (QWs) is investigated. The relaxation ratio is controlled by changing the thickness of an AlGaN buffer layer. The relaxation ratio increases from 20% to 100% with increasing the AlGaN layer thickness from 0.5 to 6.0 μm. Photoluminescence (PL) intensity reaches maximum at a relaxation ratio of 36%, which implies competing effects in radiative and nonradiative recombinations. From the viewpoint of radiative recombination, strain relaxation increases the polarization field in the QW, which decreases the electron–hole overlap. The observed gradual decrease in PL may come from this effect. In terms of nonradiative recombination, the dislocation density is nearly constant up to 4.5 μm from the AlN/AlGaN interface, and decreases at 6.0 μm. Therefore, it is difficult to explain the observed PL intensity by the dislocation‐related nonradiative pathways. Instead, relieved strain can decrease the point‐defect density. Strain relaxation can reduce the vacancy concentration as a result of increased formation energy with the partial relief of compressive strain. The effect of strain on the band structure change is also discussed, where the relieved compressive strain increases the crystal‐field split‐off component in the valence band maximum, resulting in a decreased PL intensity.