There is no fixed relationship valid for every single company at every single time.
Firstly, nominal interest rates and inflation change over time. This means real interest rates of government bonds change. You might want to buy a widely diversified portfolio of stocks at 25 times their earnings if the real interest rate is negative like it is now, but would you pay 25 times earnings for the same portfolio if real interest rate is 3%?
Secondly, earnings is affected by financing of the company because you subtract interest payments from earnings. You can think of one very strongly financed company with practically no debt and thus practically no possibility of it going every bankrupt, and another company on the verge of bankruptcy. Using P/E valuation (price per earnings), you will find very different valuations for these two companies. Using EV/EBI (enterprise value per earnings before interest) would be somewhat better but usually EBI isn't published so you need to use EV/EBIT (enterprise value per earnings before interest and taxes) and then you can compare only companies having the same tax rate. Actually for differently financed companies EV/EBIT is far better than P/E, but for a company on the verge of bankruptcy EV/EBIT also falls to indicate a low valuation, but you shouldn't invest to such a company because of its low valuation. The reason for debted companies having lower P/E is that debt is cheaper than equity, because interest rates are less than profits from stock market investing. Therefore, a company can leverage its profits by using more of the cheaper financing and leaving less need of having shareholders to provide capital.
Thirdly, the growth rate of companies differs massively. For example, Tesla has P/E ratio of 175, because investors assume electric car market grows exponentially and Tesla continues to be its leader, and that Tesla might have possibility to use its technology in other clean energy projects too than electric cars. Those assumptions might be overly optimistic, however, and you shouldn't therefore invest to Tesla at its present valuation. However, the oil and gas company Shell has P/E of 10.37, because oil use is threatened by the widespread adoption of electric cars, so the oil part of its revenue has only short future. Gas may be used for a longer period of time, but eventually clean hydrogen produced from electrolysis threatens it too. So high growth may mean P/E is high and low growth may mean P/E is low.
Also, different sectors usually have different P/E values. P/E values of banks may be low because banking is an inherently risky business, and P/E values of bulk industry like steelmaking may be low too because the product is a bulk product and small fluctuations in demand can cause large fluctuations in profitability. However, fast-moving consumer goods companies usually sell well at all parts of economic cycles, so this may justify a higher P/E despite not having massive growth rates. So riskiness of the sector can cause variations in the natural P/E. Usually higher risk needs higher returns, so higher risk investments need a lower P/E.
If a company has inherent shields against competition, a higher P/E may be justified. For example, the industrial gas sector is a sector where every company is essentially a local monopoly in a small area due to being dependent on massive capital investments and due to being ecomonically impossible to ship industrial gases across long distances. If one company sells industrial gases in a limited industrial area, it doesn't make sense for a second provider to make capital-heavy investments in the small area unless the first company is charging excessive fees from its industrial gas production. The first company knows this and decides to charge very very slightly less than excessively. Thus the second company will never establish its presence in the area. Air Liquide is an example of industrial gas company, and it has a P/E of 27.68. That is a bargain at current real interest rates despite sounding high.