Staying up all night is not healthy at all. We need our sleep to function properly and recharge.
When we don't get enough sleep we can't focus right.
It decreases our alertness. Sometimes it's unavoidable to stay up all night such as an emergency or some deadline we need to meet. And sometimes we can't sleep due to insomnia.
If insomnia is keeping you up you might have to take some Sleep Aids to get some sleep.
I've stayed up for 3 days and nights straight and I felt awful all those 3 days and nights and I could not focus.