The "where" in this piece isn't as important as the "when." Yeah, sure, it's set in Japan—try to contain your surprise—and gives us a thick slice of Japanese culture for our dining pleasure. We get to see everything from the way people eat food to the rigid social structure and the unique values that shaped the world of these isolated islands. That was part of the appeal; by introducing his nation's history to an international audience, Kurosawa helped outsiders understand and appreciate what Japan was all about.
But that doesn't matter to the movie so much as the era in which it takes place. The late 16th century marked the end of the Sengoku period, which helped put the "dark" in Japan's Dark Ages. Though technically ruled by an Emperor, he held very little actual power. Lots of his underlings, lords called daimyo, began to fight among each other over power and resources.
It got ugly. Real ugly. Bedazzled bowling-shoe ugly.
Increased trade with China led to a massive case of the grabbies, and natural disasters like earthquakes led to widespread revolt among the peasant class. This stood in stark contrast to previous era in Japanese history, when the daimyo were obeyed without question and every social caste was obligated to do its duty. The era ended at the beginning of the 17th century, when the Tokugawa clan took control of the country and put a halt to all the fussin' and a-feudin', but for a while there, it was pretty wild and crazy.
That upheaval made a perfect breeding ground for the kind of story Kurosawa wanted to tell. Bandits ran rampant, individual towns needed to protect themselves, and the every-man-for-himself free-for-all completely upended every previously established rules of propriety. It wasn't all that different from the Wild West, where people made their own laws and the only rules that worked were the ones you could enforce from the barrel of a gun. Small wonder the director loved him those cowboy movies.
More importantly, the Sengoku period produced the exact kind of tough loners who stood in stark contrast to the duty-bound samurai of other eras in Japanese history. With all those lords fighting each other to the death, you ended up with a lot of dead lords. That, in turn, led to a lot of masterless samurai wandering the countryside with nothing much to do. They were called ronin—a term you may have heard of and which literally means "wave man." Here on this side of the Pacific, we tend to love the brooding outsiders who play by their own rules. But in Japan, ronin were a lot less cool.
They had failed in their duty, and everyone knew it. They wore their shame on their faces and no other lord wanted to sign them up. But some of them still lived by a code, and while they struggled to eat, thy refused to become predators and thieves like some of their brethren did.
Kurosawa used them to show Westerners what his nation was like. We gravitated towards them as the long gunslingers of this world, then learned as the film went on that is wasn't all awesome showdowns and beers at the local watering hole. They lived hard, tough lives, and as the film notes somberly at the end, they didn't actually win much of anything.
The period that created them reflected Japan of the mid-20th century almost perfectly. Once again their world had been turned upside down. They lost World War II when the US dropped two atomic bombs on them on them and had to accept the influence of Western ideas and beliefs. It brought them a lot of benefits, but there was a real sadness too. Small wonder that they gravitated towards these wandering warriors of another chaotic era, who clung to their shabby dignity and did the best they could for nothing more than a bowl of rice and a "thank you."
If you wanted to recreate Dodge City and Tucson in the Far East, this period was the time to do it. And Kurosawa knew exactly precisely how to tweak our expectations of Western heroes for a uniquely Asian time and place. If the setting didn't match that time—and if that time hadn't matched 19th-century America's in a lot of ways that count—it might not have been the game-changing masterpiece that it became.