Worried parents of teens about to backpack through Europe will have no trouble believing hotel and hospital are actually etymologically connected. The English words hospital, hostel, hotel, and hospice are all etymologically related to the Latin noun hospes—a word having the diametric meanings "a guest or visitor" and "one who provides lodging or entertainment for a guest or visitor." (Host meaning "one who entertains guests" is also related.) The words all passed through and were altered by French before entering English, which means they are doublets—or rather, words derived from the same source but having different meanings.
The formative source of hospital, hostel, and hotel is Latin hospitale, a word referring to a house or lodging for travelers that is a derivative of the adjective hospitalis ("of a guest," "hospitable"), which developed from hospes. Hospital and hostel are direct borrowings of French words formed from hospitale, whereas hotel was influenced by French hostel. Hospice, on the other hand, traces to Latin hospitium, which shares the same meaning as hospitale—the Latin ending -tium became -ce when the word was borrowed into French. Hospice entered English in the early 19th century with the same meaning as its French and Latin sources, denoting a lodging but especially one kept by a religious order. By the end of the century, the meaning of hospice was extended to a facility providing care for the terminally ill.
The oldest doublets are hospital and hostel. Hospital is a 14th-century loanword from Anglo-French that originally designated what we would now call a hostel—a place where weary travelers could rest before pressing on with their journey. In the 15th-century, hospital came to refer to a charitable institution for the housing of the needy and then to a place for the education of young people. Today, both senses are essentially obsolete except in British law and in the names of historical institutions, such as Greenwich Hospital, which was a home for retired sailors of the Royal Navy, and Christ’s Hospital, a school in London. The familiar application of hospital as a name for an institution providing treatment for people who are sick and injured also developed during the 15th century. That use of the word was transferred to a facility for the treatment of animals roughly two centuries later:
The publike Hospitall, which the Citizens ... had founded for all kindes of Birds, to cure them in their sicknesse.
— Samuel Purchas, Pilgrimage, 1613
Similar to hospital, hostel entered the English language as a French adoption and referred to a place providing lodging for travelers. The word was common from the 14th century to the late-16th century, but thereafter inexplicably fell into disuse; it was revived in the early 19th century. Prior to the hiatus of the "lodging" sense of hostel, the word became a term in British English for student housing at a university or other educational institution. It also checked in for a brief period as a word for a town mansion belonging to a person of rank or wealth. That sense of hostel was superseded by hotel in the later half of the 17th century. Today, hotel is only encountered in that sense in literary and historical writings, especially those on the subject of French aristocracy.
In modern French, hostel became hôtel, which was anglicized as hotel in the early 17th century. Originally, hotel was used for a house or building similar to an inn that provided overnight accommodations, meals, and other services to travelers; in time, the overall structure and amenities of a hotel surpassed those of the common inn—leading to a linguistic differentiation between inn and hotel.
Groping your way to the inn—(I beg pardon—hotel).
— James Beresford, The Miseries of Human Life, 1807
For readers acquainted with the French term hôtel-dieu: that phrase is a fossil from the Middle Ages, meaning literally "hotel of God" but used for "hospital," that is preserved in the names of venerable hospitals in France; the modern French word for "hospital" is hôpital.
Although the doublets hospital, hostel, hotel, and hospice traveled different routes into the English language, they share a Latin point of departure at hospes and made stops in French, where they gained their seminal English spellings and meanings. The English words are distinct in form, but they have retained a commonness in meaning after their travels: they all relate to providing for guests or visitors of one kind or other, a characteristic shared by their hospitable Latin parent, hospes.