Lots of people publish books using their real names, but some people opt for a pen name.
Most times this is done to maintain anonymity. Either to keep their potential writing fame separate from their personal life or to protect their family from whatever their writing may reveal. Not everyone who wants to be a successful author also wants to be famous.
If an author is already well-established in a particular genre or age range, they may choose to also publish under a pen name so they may enter another genre without people making assumptions about their previous work. Just because everyone knows you write a lot of fun, quirky contemporary, doesn’t mean you don’t have an epic sci-fi thriller in you.
Sometimes it’s because a name is too difficult to pronounce, too similar to another author’s name, or because people are going to assume things about the author if they use their given name rather than their initials or a pseudonym. Boys don’t want to read a fantasy book if they know a girl wrote it. This isn’t always true, and, as a woman, it is incredibly annoying. But, truth is, having a certain name on your book may limit your audience.
It feels a bit silly to judge a book by the author’s name, but, we do judge books by their covers, and the author’s name is part of the cover.