Gensokyo used to be an isolated and haunted place in Japan inhabited by youkai, but because they terrorized the surrounding lands brave human warriors setteled into Gensokyo to watch over and fight them. As time passed, the human world began to put it's faith into science and technology and the old beliefs and superstitions faded away. Deeming it unfit for the new world Gensokyo was sealed off with the Hakurei Border, leaving the descendents of the brave warriors and the yokai to fend for themselves.
Being isolated from the human world, the residents of Gensokyo created their own culture based off of magic and spirituality. Due to their magical abilities it's quite easy for the youkai to travel across the border, but instead they've helped strengthen it so humans wouldn't wander in accidentally. However, during the last thousand years the border has weakened.
The Hakurei Shrine is the one gateway between the two worlds. It exists simultaneously in Gensokyo and the human world, but to travel across you must meet a set of unknown circumstances. Reimu Hakurei is the current maiden of the shrine and the guardian of the border.