tl;dr:
- If you try to 'explain' life has a meaning, your son might stop listening to you.
- Life might be meaningless, but it can be pretty interesting.
What you wrote resonates with me. My feelings/thoughs were similar to those of your son. The existing answers bring up valid points (and one or two I am horrified by). But I think there is something fundamental that is missing:
Your son "realized" that "life is meaningless".
You ask "How to explain to him that life is not meaningless?".
That is not the point.
I think if you try "explaining" that to him, he will sooner or laternotice the gaps in your logic. He might still like you, but he will stop taking your opinions seriously.
Think about it: A statue has a meaning. A Poem. Some pictures. But life?
Statues, Poems and pictures were created by someone with some intent or message.
The only way to argue "live has a meaning" is to assume some creator or higher force has created it with such. Your son has thought hard about the meaning of life at a young age. So I strongly doubt he is a very religious type.
A possible non-religious argument would be to call our genetic "programming" the "meaning of our life". But that information is depressing in itself - not something that would stop a suicide (ironicly, the programming itself does stop us, but that is a different topic).
Now, I guess you feel that your life has a meaning. But that is a different thing, and you cannot transfer that feeling by an explanation.
So, what can you do?
Keep talking with your son. Please do not make assumptions like "they don't have the reasoning skills of an adult with a fully matured brain". From what you wrote, your son might be more analytical than you yourself. So ask. Learn his reasoning. You might feel about things differently, but it will do both of you good if you can understand each others reasonings.
And remind him that life does not need to meaningful. It is like exploring a mysterious forgotten house: The house has no deep meaning, nor has the exploration. And we might hurt ourselves horribly while doing it. But people enjoy doing it.
Tell him that it is ok if life feels bad at the moment. If you tell him "life will get better" it might sound like a platitude for him (and it might actually be). But ask him to stay curious.
(3. There was some reason for his friend's suicide. Make sure it is not affecting our son as well. Face any other ongoing external issues. Otherwise you are fighting an uphill battle.)
- Give him the agency to make life interesting. Is his life just "enduring school so he can get a 'hopefully' get joyless job"?
Make him the one to decide what you do on holidays or summer-break. Only condition: it has to be interesting and/or a new experience.
Could be dissassembling a rusted car-wreck in your car-port. Could be spending a week with some relatives he has never seen before. Visiting a town across the border. Helping in a shelter. Climbing some mountain he has seen on television. Riding a horse. Dog-sitting. Joining a protest. Visiting a skate-park. Hunting with someone who does that thing. Applying for some absurd side-job and doing it for a month or two.
You might even consider a "I will tell the school you are ill - but only if you have a plan for the day that is more interesting!"
Remember that depression drains energy, so you might want to start with these things on good days.
Life might have no meaning - but you can help to make it interesting.