No, modding isn't illegal in itself. The line gets crossed when money enters the picture.
Selling mods, charging for access to them, or distributing cracked game files can all land you in trouble. Making a mod for your own enjoyment, or sharing it freely with a community, generally sits on the right side of that line — though always check the game's end-user licence agreement, since some publishers forbid mods outright.