is it  based on any events in history?
Yes, it is derived from the memoirs of Anna Leonowens, governess to the children of King Mongkut of Siam in the early 1860s.
The King and I
 It is based on Margaret Landon's novel, "Anna and the King of Siam" (1944), which is in turn derived from the memoirs of Anna Leonowens, governess to the children of King Mongkut of Siam in the early 1860s. 
where did the king and i come from It is based on Margaret Landon's novel, "Anna and the King of Siam"
wiki:5390527
The King and I [SEP] Introduction
The King and I is the fifth musical by the team of composer Richard Rodgers and dramatist Oscar Hammerstein II. It is based on Margaret Landon's novel, "Anna and the King of Siam" (1944), which is in turn derived from the memoirs of Anna Leonowens, governess to the children of King Mongkut of Siam in the early 1860s. The musical's plot relates the experiences of Anna, a British schoolteacher hired as part of the King's drive to modernize his country. The relationship between the King and Anna is marked by conflict through much of the piece, as well as by a love to which neither can admit.