TwinCAT includes a simulation runtime that runs without any license key on your development PC. You can:

Limitations: Cannot connect to real hardware I/O terminals without a licensed runtime on the target.

If you are a student or at a university, contact Beckhoff’s academic program. They provide free or heavily discounted full licenses for educational purposes.

If you own a Beckhoff embedded PC (CX series) or a TwinCAT Runtime device, the engineering side (development environment) for your local PC is often free when connected to the target.

If you need Beckhoff/TwinCAT for learning or development at zero cost, here are legal alternatives that effectively give you "free" functionality:

If you don’t reactivate the trial, the system runs in free run mode where the PLC stops after 2 hours. For demonstrating a sequence or testing boot-up logic, this is often enough.

Beckhoff provides a TwinCAT 3 Engineering environment that is completely free to install. You can write code, create visualizations, and simulate logic without spending a cent. However, the "Runtime" (where the code actually executes on a cycle) requires a license.