All Light had to do was conceal that he was Kira.

L had to deduce who Kira was, how Kira killed, what Kira's motivation was, what accomplices (if any) Kira had, all the while trying to keep himself and his coworkers safe, minimizing public killings, trusting the right people, while keeping the right people in the dark about his plans, keep records of his thought process, set traps without letting the right people know about it.

Literally one slip up means failure and most likely death. Even after all of this, the only reason why he died was because he ultimately made the right decision that was going to conclude with Light getting caught and a shinigami had to interfere to stop him.

L is by far the smartest person in the whole show. Smarter than Light and Near by a mile. Him dying humanizes him.