In any graph on horizontal axis we keep the independent variable and on vertical axis the dependent variable. similarly in stress strain diagram the strain is independent variable and stress is dependent variable so due to this reason strain is kept on x-axis and stress is kept on y-axis.
We take stress on the Y-axis and strain on the X-axis. On X- axis we take independent variable and on the Y -axis, the dependent variable i.e y is dependent on x, Means, you change a quantity on X and its effect is seen on Y. Here stress is dependent on strain. Actually here stress means the inter-atomic force between the atoms. This interatomic force depends on the distance between the atoms which will change by change in length ie by strain. So the stress is dependent on strain. So Stress is a dependent variable and should be taken on Y- axis with strain the independent variable on X- axis.
Though it is also said that taking stress on y and strain on x axis is conventional and we are so used to it that the convention seems more of a rule now.
See also: True Stress & True Strain | Engineering Stress-Strain Curve