If your employer offers a match on the 401(k), it behooves you to contribute at least up until the match. Even if you expect to retire early, paying a 10% early withdrawal penalty on a 100% free match is still a good deal. Otherwise, those with plans for an early retirement ought to favor the 457.
All else being equal, investors should consider the investment options and fees for each plan. If one plan offers the ETFs or mutual funds you like or it has considerably lower fees, opt for that one. Fees can be a major drag on your investment returns over 30 or 40 years, so it pays to keep them low.
But maybe you don't have to make a choice at all -- there's nothing that says you can't contribute to both! If you want to get the employer match on the 401(k) but also want the flexibility of early withdrawals, invest in both plans.
Moreover, since a 457 isn't a qualified retirement plan, the contribution limits for a 457 and qualified retirement plans like a 401(k) don't overlap. That means you can contribute the maximum amount to both plans, and that's totally fine with the IRS. In 2024, that's a potential $47,000 in tax-advantaged savings if you're under 50 and your employer offers both a 401(k) and a 457. If you can swing it, that's probably the best option of all.