Urbex has quite the reputation of being illegal—of requiring by definition trespassing. Although some urban exploration does indeed occur in areas that are legally off-limits, few "practitioners" would ever recommend that you do this. The bulk of exploration happens in places noone cares about (which explains both their abandonment and/or the fact that noone bothered to lock them up or even post a no trespassing sign.
Urbex is most commonly understood as the exploration of parts of cities that no one visits, be it abandoned buildings, steam tunnels, subway systems, or even sewers (sewers are extremely dangerous!). Infiltration, which involves exploring used/inhabited areas, is often lumped in with Urbex, but it tends to attract a different crowd. Virtually any building can be an infiltration "destination", but the most popular are architecturally interesting commercial buildings, industrial sites, and hotels. (Trying to get into hotel pools and spas is a favorite activity.)
Why do this? Novelty, thrill seeking, boredom, and photography are the main reasons. Urbex basically opens up a whole new field of sightseeing, and makes for good stories. Many explorers find the forgotten, abandoned, and otherwise undiscovered places to have a certain beauty not to be found elsewhere—hence the popularity with photographers. Infiltration is popular too for thrill seeking, but is more valued for aesthetic and other pleasures that would otherwise be off-limits (or cost money) to the explorer. Wandering around a beautiful building or a more exotic industrial site is fun for fans of architecture and photography, while stealing luxury services from, say, the Four Seasons, offers obvious rewards. Bear in mind, though, that in the latter case you are guilty of theft.
Safety is or should be the number preoccupation of any exploration. Urbex trips are often frought with danger. Abandoned buildings are abandoned for a reason. Decrepit floors and stairs might collapse under your weight, a brush against rusty metal could give you tetanus, you might run into a gang that's been playing around in the place, encounters with wild animals, etc. On the upside, law enforcement is unlikely to care too much about your being there. At worst you would probably get a fine, and be allowed to walk out on your own. Underground Urbex suffers from several physical threats—again, crumbling infrastructure can be your enemy, as well as resident weirdos and animals, but there are extra dangers from steam vents, electricity, flash floods, and poisonous gases. Make sure you know what you are doing! Danger from law enforcement has increased exponentially in the United States and several other countries following major terrorist attacks. If you are found on camera to be sneaking around subway tunnels, you may find yourself arrested on suspicion of terrorist activity. Needless to say, that's a whole lot worse than a fine for trespassing!
There are universally recommended steps to keep yourself safe while exploring, and you would be a fool not to follow them. Don't ever do this alone. Make sure that someone else knows what you are doing, and plan to check in with them at set times. Bring a phone, light source with multiple batteries, hard hat if appropriate, heavy duty boots, and some food. If trying something new, do research first either on the chosen site, or at least on the type of site.
Infiltration entails far less physical danger, but increased chance of discovery and trouble with the law. Government buildings are very nervous about terrorism, and may toss you in jail if discovered. Industrial sites have also become quite paranoid. Hotels are less panicky, so if you don't seem terribly threatening, and have not been wandering around areas off-limits to hotel guests, you are likely to get off only with a demand to leave the building immediately, or to be fined. Downtown commercial buildings tend to care the least about what you are doing, and are less likely to fine or otherwise prosecute you unless you have broken into a clearly secured area.