To be clear, a 401K is a vehicle, you make investments WITHIN it, if you choose poorly such as say putting all your money into company stock when working for the next Enron, you can still get hurt badly. So it is important to have diversity and an appropriate risk level based on your age, tolerance for risk, etc.
That said, as vehicles go it is outstanding, and the 'always max your 401K' is very very common advice for a large number of investing professionals, CFA's, pundits, etc. That said there are a few priorities to consider here.
First priority, if there is some level of company matching, grab that, it's hard to beat that kind of 'return' in almost any other case.
Second, since you never want to tap into a 401K (if you can at all avoid it) before you are ready to retire, you should first be sure you have a good 'emergency fund' set aside in the event you lose your job, or some other major catastrophy happens. Many recommend setting aside at least 6 months of basic living expenses.
Third, if you have any high interest debt (like credit card debt) pay that stuff down as fast as you can. You'll save a ton of interest (it's pretty much the same as investing the money you use to pay it down, and getting a return equal to the interest rate you are paying, with zero risk.. can't be beat. You'll also end up with a lot better cash flow, and the ability to start saving first and spending out of savings, so you earn interest instead of paying it.
Once you have those things out of the way, then it is time to think about fully funding the
401K. and keep in mind, since you don't pay taxes on it, the 'felt effect' to you pocket is about 80% or even less, of what goes into the account, so it's not as painful as you might think, and the hit to your take home may be less than you'd expect.
Contributing as much as you can, as early as you can also lets you benefit from the effect of compounding, and has a far larger affect on the balance than money put into the account closer to retirement. So if you can afford to max it out, I surely would advise you to do so.