This paper presents a method for optimisation of the material composition of functionally graded materials (FGMs) for thermal stress relaxation. This method consists of a multiscale thermoelastic analysis and a genetic algorithm. In the presented method, location-dependent unit cells representing the microstructures of two-phase FGMs are created using morphology description functions, and the homogenised material properties and microscale thermal stresses are computed using the asymptotic expansion homogenisation method. Thermal stress relaxation effects at the microscale in the FGMs are quantitatively evaluated, being reflected for the optimisation computation of the material composition. Numerical calculations are performed for a functionally graded infinite plate subjected to prescribed surface temperatures, and it is demonstrated that the optimisation with the knowledge of specific microstresses in FGMs results in not only a different trend of material composition distribution but also a different critical location for material failure from those obtained by conventional optimisation without the knowledge of the microstresses.