Updated:

1. Rotate by angle (Java 1.21.2+)

/rotate @s 90 0
/rotate @s ~45 ~
YawFacing
0South
90West
180North
-90East

Pitch is -90 straight up, 0 level and 90 straight down.

2. Face a position

/rotate @s facing 0 64 0
/execute as @a run rotate @s facing 0 64 0

/rotate accepts a single target only, so wrap it in execute as @a for everyone.

3. Face an entity

/rotate @s facing entity @e[type=villager,limit=1,sort=nearest] eyes

4. Turn a mob or armor stand

/rotate @e[type=armor_stand,limit=1,sort=nearest] facing entity @p

Moving mobs turn themselves again, so use NoAI mobs or armor stands (NoAI command).

5. Rotate with /tp

/tp @s ~ ~ ~ 90 0
/tp @a 0 65 0 facing 0 65 10

Use this before Java 1.21.2 and on Bedrock. See the tp command.

6. Keep spinning (repeating)

/execute as @e[tag=spin] at @s run rotate @s ~10 ~

In a repeating command block, every entity tagged spin turns 10 degrees each tick. Use a smaller number to slow it down or a negative one to spin the other way. Handy for display armor stands. See the tag command.

Troubleshooting

Check your command

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