I am a current master student (my field is earth sciences). Some time ago, I was sure that I should apply for a PhD right after I graduate with a master's degree. However, now I am thinking about taking a gap and working for about 5 years prior to my PhD. Will this professional experience look good or rather bad in my CV if I plan to apply for research-based PhD programs and pursue my future career in academia? Thank you.
If the job you take is research based then it could help rather than hurt. But one issue, in some places, is that letters of recommendation from academics (primarily) are very important. The US is like that. So, explore the requirements for application and keep in touch with former professors if that is an issue.
Letters in general need to confidently predict your likelihood of success in a doctoral program. Those with doctorates (academics or other researchers) who know you and your work well are in a position to do that. Others not so much.
Something else to think about is whether living for a few years on a much reduced income will be feasible for you at that time. Other things may happen in your life that make you depend on that income.
Note that "research based" can be subtle. Much (most?) of the "research" at companies (as opposed to research labs) is product based. That isn't the same thing and has much less value in many cases, though I don't know what product based earth science would look like. By "research" I intend extending what is known rather than extending what is useful.
If the job will benefit your application will depend on the type of job. If the job is say, as a lab technician and you are thinking of a PhD in Mol Bio, or if the job is an as an engineer if you are thinking of a PhD in engineering, etc. Otherwise, as others have pointed out, the main issue might be that your letters of reference from professors will be dated.
But regardless, I am of the opinion that taking a break between degrees is a great idea. I took a 6-year break between my BS and PhD and I think it helped me a lot, especially in terms of managing relationships with coworkers and supervisor, project management, etc. It is also my observation that older grad students do better than those fresh out of college, all other things being equal.
Your experience outside of academia will also give you perspective. Academics complain a lot (myself, I log about 5 complaints per hour, 10 per hour on Mondays), but after spending 5 years outside of academia, you will also appreciate how good academics have it.