Whether modding a video game is legal depends entirely on the game in question. The key is to check the license agreement that comes with it, since that document spells out what is and is not permitted.
Many games actually allow modding and even encourage it. The Sims 2 is a prime example, with a thriving community built around user-made content that the developers welcome.
So before you start tinkering, read the fine print for your specific title. If the license allows it, as many do, you are free to mod away.