There is always mystery in why poets write poems at all, and even more mystery in why they write specific poems. Nonetheless, it is far from surprising that Tennyson wrote a poem about Elaine of Astolat. The first and most obvious reason is his personal fascination with the Arthurian legends, the stories in which formed the basis for many of his poems. Connected to this is the position of Arthurian mythology within English literature. The stories of King Arthur and his court are the closest thing England has to a national epic, and it was natural that an ambitious young poet would want to write about them.
Beyond these motives, however, is the way in which the Lady of Shalott's story works as an extended metaphor for the life of the poet or other creative artist. The Lady spends her life in isolation, weaving a beautiful tapestry and watching the outside world in a magic mirror. In order to create her work, she must keep the world at a distance. While the Lady of Shalott defies the curse and dies, Tennyson remains a detached artist as he describes her doing so. He is able to explore the boundaries of art without transgressing them by sending his character out into the real world to die.