The words in, inn sound the same but have different meanings and spellings. Why do in, inn sound the same even though they are completely different words?
The answer is simple: in, inn are homophones of the English language.
Within the limits, bounds, or area of: was hit in the face; born in the spring; a chair in the garden.
From the outside to a point within; into: threw the letter in the wastebasket.
To or at a situation or condition of: was split in two; in debt; a woman in love.
Having the activity, occupation, or function of: a life in politics; the officer in command.
A public lodging house serving food and drink to travelers; a hotel.
A tavern or restaurant.
Chiefly British Formerly, a residence hall for students, especially law students, in London.
Definitions from The American Heritage® Dictionary of the English Language, 4th Edition and Wordnik.
Homophones (literally "same sound") are usually defined as words that share the same pronunciation, regardless of how they are spelled.
If they are spelled the same then they are also homographs (and homonyms); if they are spelled differently then they are also heterographs (literally "different writing").