Many bodies in our solar system have a magnetic field. The first one I can name off the top of my head would be Jupiter, but other planets and even moons have them too. The Sun has one as well.
Also, Mars used to have one, but since it was so small it couldn't sustain itself and it eventually cooled. Before that time, the planet was probably habitable to some degree. Certainly not like Earth though.