Is modding a game legal?
It depends heavily on what the mod does and how it is distributed, and the honest answer is that most modding operates in a space the rights holder tolerates rather than one where the modder has clear legal rights.
The legal baseline. A game is copyrighted software. Modifying it can implicate copyright in the code and assets, and the licence agreement you accepted governs what you may do. Most licence agreements technically prohibit modification and reverse engineering, whether or not the publisher enforces it.
What is generally safe:
Officially supported modding. Many games ship with mod tools, SDKs and workshop integration. Bethesda, Valve, Paradox and others actively encourage it, and this is unambiguously permitted within the terms provided.
Mods distributed as patches that require the original game — containing only your own new content and instructions to modify, not the publisher's assets.
Purely local changes to your own copy that you never distribute.
Where it becomes clearly infringing:
Distributing copyrighted assets. A mod including the publisher's models, textures, audio or code is redistribution regardless of intent.
Using assets from other games or media. Mods importing characters, music or models from another franchise are the most reliably taken down, and this is why fan projects using Nintendo properties are removed so consistently.
Circumventing copy protection, which is separately unlawful in many jurisdictions under anti-circumvention provisions.
Total conversions distributed standalone, playable without owning the original.
Commercial mods, selling something built on someone else's IP.
Multiplayer cheating — mods providing advantage breach terms and result in bans, and in some cases anti-cheat circumvention has attracted legal action.
Where it gets awkward:
Paid mods have been attempted and repeatedly proved contentious, since revenue sharing and IP ownership are unresolved.
Fan projects and remakes are regularly issued takedowns even when non-commercial and made from scratch, because trademark and character rights apply independently of code.
Read the specific game's modding policy — many publish one.