Why Underscores are Not Recommended?
Google views hyphens in URLs as word separators while an underscore in your url will not be recognized. This means using hyphens makes it much easier for Google to figure out what a page is about. For example, a URL containing the phrase "my_page" would be interpreted as "mypage" instead of "my page".
Google goes into detail regarding optimized URL structure in their Search Console Help guidelines. Matt Cutts explained why they do this and how it came about in this Webmaster Help video:
Why Do Hyphens in URLs Matter?
Underscores in URLs aren’t recognized by Google, a URL containing "my_page" will look like “mypage”. A URL containing “my-page” will be interpreted as “my page”. This matters because “my page” is easier for Google to interpret, making it appear more relevant to queries about the “my page” topic (“what is my page”, “how to create my page”, etc.).
The easier it is for Google to read and interpret the URL, the easier it is to determine relevance (and thusly rankings) for a search query.
Say, for example, you have a page about weight loss tips. You have to choose between two URL structures: "tips_for_weight_loss" or “tips-for-weight-loss”. If you choose the first one, Google will only see “tipsforweightloss”, which will harder for it to understand.
On the other hand, "tips-for-weight-loss" will look like a normal sentence, and therefore relevant to a wide variety of searches:
"Tips for instant weight loss"
"Instant weight loss tips"
"Weight loss tips"
The page using the second URL option, the one with the hyphens, has a higher probability of appearing in search results than the first.
As an added bonus for URLs using hyphens, any links using the URL as anchor text will also be interpreted as including keywords in the anchor text. They are also easier for users to read, as underscores can easily be mistaken for spaces, leading people to type in the wrong URL when trying to visit your site.
What If I’m Already Using Underscores in URLs?
To be clear, URL punctuation is not a ranking signal. It’s used a only to read and interpret a URL when indexing it. So if you’re currently using underscores in your URLs and you’re getting the results you want, there’s no need to change. In fact, changing your URLs to hyphens can cause a short-term ranking loss because Google needs to recrawl, reindex and reinterpret the new URL structure.
In fact, John Mueller explicitly advises against redirecting URLs just to resolve the underscore vs. hyphen issue. Check out his Webmaster Hangout here for the full explanation.
For a perfect example of this, look at Wikipedia. Wikipedia uses underscores in all of its URLs, but consistently dominates SERPs for informational searches. For example, check out the page for the Grand Place here. Note that the page is "grand_place", not “grand-place”.
Now check out the SERP:
There’s the Wikipedia page right there at the top.
Since Wikipedia’s on-page optimization, off-page signals and overall domain authority are so strong, underscores in its URLs don’t have much of an impact.
What if I’m not seeing the results I want?
Sadly, not everyone can be Wikipedia. If you are using underscores in your URLs and not seeing results that you’d like, use 301 redirects to move to a URL structure using hyphens.
Going back to the original, if your page "example.com/my_page" isn’t ranking very well, change your URL structure to use hyphens, and then publish the page at “example.com/my-page”. Set up a 301 redirect to send all humans and crawlers to the new URL.
Again, you should only do this if you’re struggling to perform well in search results as it will take Google some time to crawl and index the new URLs.