Overview
true does nothing and exits with status 0, which means success. It is a placeholder for a command that must succeed, for example as the condition of an endless loop, or to keep a script going when a command may fail (cmd || true). Its partner false always fails.
Background
The true command exists so that a shell script can say "success" without doing anything. Today the name covers the Bash builtin, GNU true, the true that macOS ships, and the true applet in BusyBox. They agree on exiting with status 0 and printing nothing.
Examples
Show that the exit status is 0:
true; echo $?
Run the second command because the first succeeded:
true && echo yes
Keep a script going when a command may fail:
false || true; echo continued
Use it as the condition of a loop that stops by itself:
n=0; while true; do n=$((n + 1)); test "$n" -ge 3 && break; done; echo "$n"
Use it as an empty then branch, so the if has a body:
if true; then true; fi; echo ok
Common mistakes
true ignores its arguments, so true anything still succeeds. In a script with set -e, a failing command stops the script unless it is followed by || true. The shell also has the : builtin, which does the same job; use whichever your team knows. A loop while true needs a break or an exit, or it never ends.
Portability
The Common examples ran in the Bash builtin, GNU true, macOS /usr/bin/true and BusyBox true with the same output. GNU true --help and --version print text, and other implementations ignore them. The Common examples were executed on Bash 5.2, GNU coreutils 9.11, macOS system tools, and BusyBox 1.37.0 (see the development guide for the exact check).
About GNU true
GNU true is part of GNU coreutils, and this page's checks ran coreutils 9.11. This view is the executable, which runs when you call it by path, as in /bin/true, or when the shell has no builtin of that name.
References
Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.