The goal in retirement savings is to sock away as much as you can reasonably afford to. Elective deferrals to company plans provide a mechanism to save money for retirement and defer income tax.
Elective Deferrals are amounts contributed to a plan by the employer at the employee's election and which, except to the extent they are designated Roth contributions, are excludable from the employee's gross income. Elective deferrals include deferrals under a 401(k), 403(b), SARSEP and SIMPLE IRA plan. https://www.irs.gov/retirement-plans/plan-participant-employee/definitions
One issue with investing a percentage of your bonus, especially if you are a higher-income employee maxing out your 401(k), is that it might cause you to hit your annual contribution limit, currently, $19,500 ($26,000 if you are 50 or older), before the calendar year is up. And if you hit the $19,500 cap too early in the year, you could miss out on company matches in the later months.
Here is an example, let's say you earn $200,000 and you are under age 50 (not eligible for catch-up contributions). By contributing 10% of your annual salary, you can stretch your contributions all the way into December. If you contribute any amount less than 10% you will not have contributed up to the $19,500 maximum by December. If you contribute more--let's say 15%--you will have already maxed out your $19,500 maximum contribution somewhere around the beginning of August, so you would miss out on collecting more than four months' worth of employer match. In the example above, 10% is the sweet spot in terms of 401(k) contribution percentage, where (depending on your salary) you are not exceeding the annual IRS contribution limit before the end of the calendar year, which will also allow you to also nab the full employee match. But also be aware that not all plans work this way--some plans match after-tax contributions or include provisions that "true-up" or reconcile the employer contribution to make sure employees get the maximum potential match. If you're not sure how your plan works, ask your benefits department or consult the plan document.