The digital-education platform Chegg Inc. on Monday said it would slash nearly a quarter of its staff, a move it said would free up space for longer-term investments as it tries to offer more than just academic guidance to students and use more artificial intelligence.