The correct allocation of shares / bonds depends on your willingness to risk and the period for which you can put the money away.
When investing the costs, expected return, and volatility are relevant. More return means more volatility. Shares have a high return and high volatility. Government bonds have a low return and low volatility. There is no high return with low volatility, because if that would exist everyone would invest in it (reducing the return).
For younger investors (<40 years) with a long investing horizon (20+ years), a good ratio is 70% shares and 30% bonds. That seems optimal for the risk / return ratio, and optimal for a 3% annual withdrawal rate (see safe withdrawal rate). Always keep a healthy amount of “emergency money” in cash (e.g. 6 months worth of expenses).
A portfolio of 100% stocks is the most profitable, but also has the highest volatility. By investing part in bonds, you significantly reduce volatility, the return you yield for it is often worth it for peace of mind.