Firstly, we know that 12 years prior to the current storyline Shanks:
- Made Windmill Village of east Blue his base for at least a year
- Had the scars on his eyes
- Had obtained the Gomu Gomu Devil Fruit from an enemy pirate
- Was well-known in Grand Line and New World for his duels with Mihawk
My theory states that Shanks wasn’t a Yonko yet but was a very powerful pirate nonetheless. During one of his adventures he comes across the Gomu Gomu DF and takes it. I’d like to point out that the Gomu Gomu DF and the Yami Yami DF look very similar in colour and shape. Now Blackbeard in his hunt for the Yami Yami DF hears/sees that Shanks obtained the purple DF and mistakes the Gomu Gomu DF for the Yami Yami DF.
Blackbeard goes and fights Shanks and whether Blackbeard overpowers Shanks or somehow sets a trap is unknown but somehow Blackbeard gave Shanks his scars. During their fight Shanks learns something about Blackbeard or obtains shocking information that makes Shanks question himself and the era. As a result of this he recluses himself to the weakest sea to gather his bearings.
There he gets acquainted with Luffy and Luffy says/does something that makes Shanks get back his drive and resolve. As a result he sails back to the New World where he rises up to the Yonko status.
*Theory by Carefulyoi