The most important part of beautiful code, formatting, adds no features or performance benefits.*
Just like a poem, programmers use whitespace to give code shape. Spaces, tabs and returns get used to shift code horizontally and vertically.
This shifting adds meaning to reading the code. Putting negative space around a value draws attention to it, like the border on a framed picture. Indenting code indicates a relationship of hierarchy, shows its dependency.
The computer ignores whitespace. In fact, readying a web app to deploy involves automatically removing all whitespace from the code. Yet it's so fundamental, an experienced programmer looking at unformatted code experiences immediate distaste and distrust.
The saying goes, "form follows function". Code has to work first. But just working isn't enough. It also has to be an object of beauty. The specific rules of the formatting don't matter much. They just need to be meaningful and consistent.
Spending time and attention on actions that don't add features is wasteful. Everyone's budget is eventually finite. No one can afford to be wasteful everywhere.
But being wasteful intentionally can be a gift, an offering, luxurious.
Making something beautiful requires choosing what to waste.
* EDIT: changed from "adds no measurable value" – formatted code has been proven to have lower bug density, easier refactoring, etc.