Updated:

1. Start a raid

/effect give @s minecraft:bad_omen 600 0

Walk into a village with Bad Omen to start a raid. In Java 1.21+, it turns into Raid Omen in the village and the raid begins shortly after. On Bedrock: /effect @s bad_omen 600 0. Higher amplifiers, up to 4, add more waves.

2. Clear Bad Omen

/effect clear @s minecraft:bad_omen

Drinking milk works too. Bedrock clears all effects with /effect @s clear.

3. Disable raids (Java)

/gamerule minecraft:raids false

In 1.21.10 and earlier use /gamerule disableRaids true. The new rule flips the meaning of true and false. See the gamerule list.

4. Remove all raiders (Java)

/kill @e[type=#minecraft:raiders]

The raiders tag covers pillagers, vindicators, evokers, ravagers, witches and illusioners. See the kill command.

5. Summon raiders

/summon pillager ~ ~ ~5
/summon vindicator ~ ~ ~5
/summon evoker ~ ~ ~5
/summon ravager ~ ~ ~5

6. Give Hero of the Village

/effect give @s minecraft:hero_of_the_village 600 4

This is the effect you get for winning a raid. Villagers give discounts and sometimes gifts. The last number is the amplifier (0 is level I), and higher levels mean bigger discounts. See the villager shop command for custom trades.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.