Use the “Companion Spawner” item in the crafting table to spawn the companion. You can also use /companion command in chat to spawn a companion but if you are in survival mode your health will go at 0.5 half hearts. Companions will try to follow you and when you hit a mob they will teleport near you and they will attack the mob. When one of your companions has killed some mobs he will level up and he will become more powerful! Only the level of your companions is saved when you exit the game, so you have to re-spawn them when you re-enter in the world.