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 no Mi Devil Fruit and takes it. I’d like to point out that the Gomu Gomu no Mi and the Yami Yami no Mi look very similar in colour and shape. Now Blackbeard in his hunt for the Yami Yami no Mi hears/sees that Shanks obtained the purple devil fruit and mistakes the Gomu Gomu no Mi for the Yami Yami no Mi.
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