Johan Renat & Birgitta were real persons. They were taken as prisoners of war and Renat was eventually enlisted in the Russian army with the promise that he did not have to take part in campaigns against Sweden, his home land. He was instead sent to Siberia and served as a cartographer before being taken captive by the Dzungar Khanate. Here Renat was made to serve in the Dzungar military, now against Qing China.
The city of Tobolsk did indeed house Swedish prisoners from the Great Northern War. They helped build the city, and some settled there.
The film is based on a series of Russian books, the first of which is "Tobol. Many Are Called". But these do not seem to be available in English.