They are named after the sun, the moon and the five planets that are observable with the naked eye. Of course, all these celestial objects are also personified as deities in Hindu mythology.
सोमवार - Moon (same as 'Monday')
मंगलवार - Mars
बुधवार - Mercury
गुरुवार (बृहस्पतिवार) - Jupiter (The planet/diety is called बृहस्पति but is given the title गुरु - 'teacher')
शनिवार - Saturn (same as 'Saturday')
रविवार - Sun (same as 'Sunday')
The 'planet' to 'day of the week' relationship is the same as in many other languages.