First, choose a historical period that interests you. It could be the Renaissance, the Wild West, or the World War II era. Then, do a lot of research on that period. Learn about the daily life, the social norms, the language, and the major events. After that, come up with a unique story idea that can fit into that historical setting. For example, if you choose the Viking age, you could write about a young Viking who goes on an unexpected adventure.
To start writing historical fanfic, begin by immersing yourself in the history. Read books, watch documentaries, and visit museums related to the period you want to write about. Next, think about the characters. You can create fictional characters or use real historical figures in a fictionalized way. For example, if you're interested in the Elizabethan era, you could create a story where Shakespeare has a mysterious encounter. Then, outline your story, making sure it adheres to the historical context as much as possible.