To "hack" a game means, in short, to cheat in the game in order to achieve certain results. Minecraft can be modified in several ways, given below.
Steps
Method 1 of 3: How to use codes in the game

Step 1. Create a new world

Step 2. Make sure the option to use codes is enabled

Step 3. In the game, press English
the letter t to open a command window.

Step 4. Enter the command to manipulate the game
For example, enter "/ time set 0" to change the time of day to sunrise
Method 2 of 3: Making yourself invulnerable

Step 1. Open an inventory editor such as INVedit

Step 2. Put the armor on your player

Step 3. Set the damage to a very small negative value (eg -40000)

Step 4. Save the world

Step 5. Open the saved world

Step 6. You will be invulnerable while wearing armor
Note: You will be vulnerable to falls, fire and water
Method 3 of 3: Other options

Step 1. Find tutorials and download the dedicated Cheat Engine

Step 2. Install mods that allow you to make changes to the game, for example INVedit or MCedit.