How Important Is Mastering?

Have you ever been really close to the finish line and then blown it at the very end? The final stage of a song’s birth (after the writing, recording and mixing) is mastering. How important is it? If it is important, why?